Skip Menu |
 

This queue is for tickets about the HTML-FormFu CPAN distribution.

Report information
The Basics
Id: 39957
Status: open
Priority: 0/
Queue: HTML-FormFu

People
Owner: Nobody in particular
Requestors: benvanstaveren [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Feature request: ability to access form in constraint/validator/etc. callback
Download (untitled) / with headers
text/plain 331b
It'd be nice to have access to the form object itself inside any callback that's declared for constraints, etc. Right now they all get called as: $callback->($value, ....) Turning that into $callback->($value, ...., $self->form) would work great. Haven't got access to my devel machine at the moment so can't attach a patch.
Download (untitled) / with headers
text/plain 576b
Because some processors do $callback->( $value ) and some do $callback->( $value, $params ) I'm wary of adding another positional argument, in case it gets too confusing. An alternative would be adding a new method to replace callback(), while leaving callback() working as before, but possibly deprecated. Or we could turn $params into an object that can still be accessed as a hashref, like now, but could also provide $self or $form via methods. I'm still undecided of the best way forward, so I'll leave this open for now as a reminder, and for further comment.
Download (untitled) / with headers
text/plain 1.1k
On Thu Dec 10 08:33:45 2009, CFRANKS wrote: Show quoted text
> Because some processors do > $callback->( $value ) > and some do > $callback->( $value, $params ) > I'm wary of adding another positional argument, in case it gets too > confusing. > > An alternative would be adding a new method to replace callback(), while > leaving callback() working as before, but possibly deprecated. > > Or we could turn $params into an object that can still be accessed as a > hashref, like now, but could also provide $self or $form via methods. > > I'm still undecided of the best way forward, so I'll leave this open for > now as a reminder, and for further comment.
I've actually just created a new Callback constraint called CallbackWithForm that will actually handle it, the changes basically involve not passing positional arguments but passing a hash of options: e.g. obj->callback(value => $value, params => $params, form => $self->form) I've not yet had the chance to really dig into FormFu guts but if there's a way that $params can be an object with a few methods to provide $form/$self (while still being accessible as a hashref for backward compatibility), that seems to be the "nicer" solution in a way.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.