views:

68

answers:

2

I get this error from my CGI script:

my_circle.pl: [FormBuilder] Warning: metro: No options specified for 'select' field at /home/ecoopr/ecoopr.com/CPAN/CGI/FormBuilder.pm line 1407, referer: http://kkarnam.ecoopr.dyndns.org:880/home.pl

Can you suggest me what might be the problem?

+1  A: 

As the error message says, you are probably trying to construct a select form widget without specifying any options.

Find out what is triggering that part of CGI::FormBuilder. You can use something like Carp::Always to turn all errors and warnings into stack traces so you can work back to the line of code that started the problem.

The relevant code is the anonymous hash construction in the prepare method, which looks like its expecting you to provide some options for select:

1406         # Create a struct for each field
1407         $tmplvar{field}{"$field"} = {
1408              %$field,   # gets invalid/missing/required
1409              field   => $field->tag,
1410              value   => $value[0],
1411              values  => \@value,
1412              options => [$field->options],
1413              label   => $field->label,
1414              type    => $field->type,
1415              comment => $field->comment,
1416              nameopts => $field->nameopts,
1417              cleanopts => $field->cleanopts,
1418         };
brian d foy
Thanks for the reply it was useful> I was able to solve the issue. That was a warning actually the error was triggered at some other place.
kiran
Maybe you can give us a description of the problem so other people can learn from it.
brian d foy
A: 

Make sure there are some options defined for selects.
For example, consider this form field definition:

$form->field(
    name     => 'dept_id',
    label    => 'Dept',
    type     => 'select',
    options  => \@dept_options,
    required => 1,
);

If the @dept_options array is empty, CGI::FormBuilder will issue the warning.

eugene y
Yeah.. got that. Actually i was JS to load the options array so I had not specified the default one.That JS function was called after the page was loaded i.e on change of drop down so there was no default value.Thanks for the reply it was really useful
kiran