开发者

Why does Perl's CGI::FormBuilder complain about 'No options specified for select'?

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 prob开发者_运维技巧lem?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜