Topic: array/table style form with checkboxes
I am looking for a railesque solution for following situation:
I have an array of permissions and an array of roles.
Each role can have 0-n permissions. Each permission can belong to 0-n roles.
To assign permissions to roles i display a form with two dimensional array of checkboxes (roles on the x-axis, permissions on the y-axis).
I see following solutions for this form:
- with AJAX: onClick/onChange handler to send
and if it is checked or unchecked
to the controller. the controller can figure out role and permission, handles assignment/removal and returns just the new checkbox trough a partial
- with Submit button: give the checkboxes a name like
and a value of <%=perm.id%>
. In the controller loop trough all roles and get the according parameters. Get the permissions and assign to role.
especialy the second example seems to complicated and i think there is something easier (i.e. arrays ?)
thanks for hints and ideas...