2014-10-03 37 views
1

是否有任何方法可以在字段'prg_id'的表单字段选项方法中访问表单字段'wklloc_id'的值?HTML :: FormHandler对表单字段的访问

我的表单包含(其中包括)以下字段:

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

在这一点上我选择了田法“prg_id”载:

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 ] }); 

是可以设置的值将变量(即2)绑定到字段'wklloc_id'的值,以及如何做到这一点?在提交之前,请注意这一点。

回答

2

选择字段的值与其他字段的设置方式相同,即它来自init_object,来自参数值或来自默认值。对于你的情况,如果你想让这个字段以'value'2开始,那么只需在你的字段定义中加入:default => 2。