简体   繁体   中英

HTML::FormHandler access to form field

Is there any way to access the value of form field 'wklloc_id' in the form field options method of field 'prg_id'?

My Form contains (amongst others) these fields:

has_field 'wklloc_id' => ( type => 'Select', label => 'Winkel(locatie)' );
has_field 'prg_id' => ( type => 'Select', empty_select => 'Kies eerst een Winkel(locatie)', label => 'Productgroep' );

At this point my options method for field 'prg_id' contains:

sub options_prg_id
{
  my ($self) = shift;

  my (@prg_select_list,$productgroep,$productgroepen);

  return unless ($self->schema);

  $productgroepen = $self->schema->resultset( 'WinkelLocatieProductgroepen' )->search( {}, { bind  => [ 2 ] } );

Is is possible to set the value of the bind variable (ie 2) to the value of field 'wklloc_id' and how does one do that? Mind you this is needed before any submit.

The value of a select field is set the same way as other fields, ie it comes from an init_object, from parameter values, or from a default. For your case, if you want this field to start with the 'value' 2, then just put: default => 2 in your field definition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM