[html-formfu] problem with setting options on select element

mohanprasad mohan at thebizmo.com
Fri Mar 13 14:25:32 GMT 2009


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.

Best Regards,
Mohan
-- 
View this message in context: http://n2.nabble.com/problem-with-setting-options-on-select-element-tp2473689p2473689.html
Sent from the HTML-FormFu mailing list archive at Nabble.com.




More information about the HTML-FormFu mailing list