2009/3/13 mohanprasad <mo...@thebizmo.com>: > > Hello, > > I am trying to set options for a select element in a form. > my code is as follows > > sub content :Chained('stash_product_name') PathPart('') Args(0) > FormMethod('load_form') { > my ($self, $c) = @_; > $c->stash->{'template'} = "restricted/add/sample.tt"; > my $cc = $c->user->country || 'US'; > # Get Price rules for the country code > my $price_rule = > $c->model('Database::PriceRule')->search({country_acronym => $cc, > "LOWER(payment_method)" => "creditcard"}); > my @price_rules; > while(my $row = $price_rule->next) { > push(@price_rules, [$row->price_structure_id, $row->value]); > } > my $form = HTML::FormFu->new; > $form = $c->stash->{form}; > my $price_cat_element = $form->get_element({ type => 'Select', name => > 'price_structure_id'}); > $price_cat_element->options(@price_rules); > } > > sub load_form { > my ( $self, $c ) = @_; > return { 'load_config_file' => "restricted/add/sample.yml" }; > } > > I am getting the following error. > Caught exception in Sample::Controller::Restricted::Add->content "Can't call > method "options" on an undefined value at > /home/mohan/search/script/../lib/Sample/Controller/Restricted/Add.pm line > 184." > > I tried to print the values that > Could you please tell me where i am doing wrong.
Hi, You should be using get_field() - not get_element() get_element / get_all_elements are not for common-use. Cheers, Carl _______________________________________________ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu