On 29/05/07, chylli <[EMAIL PROTECTED]> wrote:
HI, I'm a newbie to HTML::FormFu
Now I want to write a select elemnt whose options are from 1900 to
2000, but how to write my yaml file ?
like following :
- type: multi
container_attrs:
class: vertical
label: birthday
elements:
- type: select
name: year
values: [year, 1900, 1901, 1902 ..... 2000]
- type: select
name: month
values: [month, 1,2,3,...12]
- type: select
name: day
values: [day, 1,2,3,..31]
I must write the year form 1900 to 2000. that is so urgly. I think
there must be a clearer way to do that. Can you teach me ?
Hmm, the ideal solution would have been if YAML supported some kind of
range definition, but I can't see anything like that in the spec.
This looks something that would be quite common - so I've added the
functionality to the group element (which select is a sub-class of).
There's a new value_range() method, which works like values(), but
expects an array-ref of at least 2 values.
So, this YAML is equivalent to the following perl code:
---
element:
type: select
name: year
value_range: [1900, 2000]
$form->element({
type => 'select',
name => 'year',
values => [ 1900 .. 2000 ],
});
and with more than 2 values:
---
element:
type: select
name: year
value_range: [year, 1900, 2000]
$form->element({
type => 'select',
name => 'year',
values => [ 'year', 1900 .. 2000 ],
});
You'll have to update from svn to get these changes.
Cheers,
Carl
_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu