Subject: | Handling of checkbox items |
It seems to me that the current API is not very intuitive for handling checkbox data/options in the case where the values are generated dynamically and not known ahead of time.
Checkboxes that are related will have the same "name" and the "values" will (normally) differ. When submitted to a web server the data (often) looks like an array with the same name as the checkbox(es) and a list of values. (Unless there was only one value selected.)
A person will often be able to determine the name of expected options, but not the necessarily the number or values of the options.
I'd like to be able to select a form and then do something like:
my @choices = $form->checkboxes(name => 'options');
and get something like an array of checkbox items in the form that have a name of 'options'. These could be HTML::Form Inputs...
Expanding on this, perhaps something like:
my @unchecked = $form->checkboxes(name => 'options', state => 'unchecked');
Would only return the unselected checkboxes with a name of 'options'.
Possible values for 'state' could be something like 'checked', 'unchecked' and 'all' with 'all' being the default.
While on the subject of checkboxes...
;-)
At times a person may want to simply check all the boxes of a particular name, regardless of "value". The current API relies heavily upon determining the values first...
If given a list of the checkboxes as described above, it would be very nice to be able to do something like this:
my @unchecked = $form->checkboxes(name => 'options', state => 'unchecked');
foreach (@unchecked) { # play with the state of the checkbox
# no messing arround with finding out what possible values are...
$_->set_state('checked');
}
It would also be nice to be able to do this:
my @choices = $form->checkboxes(name => 'options');
foreach (@choices) {
# invert our selections
$_->click(); # now it is the opposite of what it was...
}
Having a "click" method for a checkbox seems a bit intuitive for me. (Could get really into it and have 'select', 'deselect' and 'click' or 'toggle'... but, I think that may be overboard.)
BTW... I *really* like this module! Nothing above is meant to be taken negatively. Simply suggestions for future development.
Thanks,
Phillip
P.S. This is my first entry into RT here... I hope it likes gt and lt symbols!