[Html-widget] Setting field values using query parameters
    Will Hawes 
    info at whawes.co.uk
       
    Fri Oct 13 18:17:24 CEST 2006
    
    
  
When a user initially visits a form (i.e. prior to submission), I'd like 
to be able to set field values using query parameters. For example my 
user might click a link such as 
"http://www.domain.com/view_form?field1=value", with field "field1" 
displaying "value" as a result.
As far as I can see the only way to do this at present is to call 
$widget->process( $request ), but that validates all the elements. I 
don't want any validation until the form has been submitted. At this 
point all I want to do is set some field values. I think what I'm after 
is something along the lines of
sub fill {
   my( $self, $values ) = @_;
   for my $e ( $self->find_elements ) {
     my $name = $e->name;
     my $value = $values->{$name};
     $e->value($value)
       if( defined $value && $e->can('value') );
   }
}
No provision in the hacked up example for checkboxes etc but hopefully 
you get the idea.
I'd be slightly surprised if something like this doesn't already exist - 
have I missed it?
    
    
More information about the Html-widget
mailing list