On 2/9/07, Carl Franks <[EMAIL PROTECTED]> wrote:
Yes, HTML::Widget seems to be in limbo at the moment.
I've just made public my intended replacement, called HTML::FormFu.
Carl,
Thanks for the clarification. I'll wait and watch developments for a while.
> I'm quite new to the intricacies of building such applications, and am
> a bit thrown by some aspects of H::W.
Could you expand on that any further, and I'll see it it's anything
I've already dealt with?
My problem is with constraints. My application is heavily derived from
the Catalyst tutorial code and I have a form I'm using to edit user
and role details. I populate this with data from the database, except
for the encrypted password. I want to accept non-password changes
and/or a new password.
I have no constraints or filters, yet the form fails to validate
unless I provide a new password. It's as if there's a "phantom" 'All'
constraint there which I can't remove.
What's happening?
---- Start Code----
sub make_edit_widget {
my ($self, $c, $user, $roles) = @_;
# Create an HTML::Widget to build the form
my $w = $c->widget('user_form')->method('post');
# Use custom class to render each element in the form
$w->element_container_class('FormElementContainer');
# Get all known roles from the database
my @roleObjs = $c->model("CalendarDB::Roles")->all();
my @roles = map {$_->id => $_->role} sort {$a->id cmp $b->id} @roleObjs;
# Get the team list from the database
my @teamObjs = $c->model("CalendarDB::Teams")->all();
my @teams = map {$_->id => $_->name} sort {$a->name cmp $b->name} @teamObjs;
# Extract the user's roles
my @role_ids;
while (my $role = $roles->next) {
push(@role_ids,$role->role_id->id);
}
# Create the form fields. We show the username but don't accept any edits.
$w->element('Textfield','first_name')->label('First
Name')->size(40)->value($user->first_name);
$w->element('Textfield','last_name')->label('Last
Name')->size(40)->value($user->last_name);
$w->element('Textfield','username')->label('Username')->size(10)->value($user->username)->
attributes({readonly=>'readonly'});
$w->element('Textfield','passwd')->label('Password')->size(20);
$w->element('Textfield','email_address')->label('Email')->size(40)->value($user->email_address);
$w->element('Select','team_id')->label('Team')->options(@teams)->selected($user->team_id->id);
$w->element('Select','roles')->label('Roles')->options(@roles)->
multiple(1)->size(3)->selected(@role_ids);
$w->element('Submit','submit')->value('submit');
# Return the widget
return $w;
}
----End Code----
Thanks for any clues,
Dave
_______________________________________________
Html-widget mailing list
Html-widget@lists.rawmode.org
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget