[html-formfu] Please help me with HTML::FormFu::Model::DBIC

Octavian Rasnita orasnita at gmail.com
Wed Jan 27 15:55:30 GMT 2010


I use the following element for showing all roles in the user add form:

<elements>
name roles
type Checkboxgroup
<model_config>
resultset Role
</model_config>
</elements>

Octavian

----- Original Message ----- 
From: "Alex Povolotsky" <tarkhil at over.ru>
To: "HTML Form Creation,Rendering and Validation Framework" 
<html-formfu at lists.scsys.co.uk>
Sent: Wednesday, January 27, 2010 4:25 PM
Subject: [html-formfu] Please help me with HTML::FormFu::Model::DBIC


> 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 at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu 




More information about the HTML-FormFu mailing list