Hello!

=== User.pm ===
__PACKAGE__->has_many(
  "user_roles",
  "Security::Schema::Result::UserRoles",
  { "foreign.user_id" => "self.id" },
);

__PACKAGE__->many_to_many(qw(roles user_roles role_id));
=== User.pm ===

=== Roles.pm ===
__PACKAGE__->has_many(
  "user_roles",
  "Security::Schema::Result::UserRoles",
  { "foreign.role_id" => "self.rid" },
);
__PACKAGE__->many_to_many(qw(users user_roles user_id));
=== Roles.pm ===

=== UserRoles.pm ===
__PACKAGE__->belongs_to(
  "role_id",
  "Security::Schema::Result::Roles",
  { rid => "role_id" },
);
__PACKAGE__->belongs_to(
  "user_id",
  "Security::Schema::Result::User",
  { id => "user_id" },
);
=== UserRoles.pm ===

=== edit.yml ===
---
model_config:
  resultset: User
elements:
  - type: Hidden
    name: id

  - type: Text
    name: username
    label: Login
    constraints:
      - Required

  - type: Password
    name: password
    label: Password
    constraints:
      - type: Equal
        others: password2
      - type: MinLength
        min: 6
        message: Password must be at least 6 characters long
    transformers:
      - type: PassHash
        password: passmd5
        hash: MD5
        digest: hexdigest

  - type: Password
    name: password2
    label: Password again

  - type: Checkboxgroup
    name: roles
    model_config:
      default_column: rid
      label_column: rolename
      link_values:
        role_id: rid

  - type: Submit
=== edit.yml ===

For editing, works well

But what should I do to show checkboxes when CREATING a user? I'd like to set roles at once.

Also, please supply me with WORKING form, allowing me to show in one form all existing roles with checkboxes for removing them and an empty line to add a new one.

It should be rather primitive, but I could not dug it out of documentation (

Alex.


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to