[html-formfu] defaults_from_model doesn't call deflators
Moritz Onken
onken at houseofdesign.de
Tue Feb 5 10:02:18 GMT 2008
Hi.
it's HTML::FormFu::Deflator::Strftime not
HTML::FormFu::Deflator::DateTime which allows me to stringify the
DateTime object to a string which fits to the locale of the user.
I can't do this with DBIC because I have no access to the $c->user
object there (using catalyst)
As a diagram (thanks to Brian ;-) )
+------+ <---- (FormFu Strftime deflator) +------------+ <---- ( DBIC
DateTime inflator ) ---- +-------+
| FORM | | Controller
| | MODEL |
+------+ ----> (FormFu DateTime inflator) +------------+ ----- ( DBIC
DateTime deflator ) ---> +-------+
I do not call $form->render because I use FormFu to create a JSON file
to load a form using ExtJS. FormFu does all the validation etc. but
doesn't render the form itself.
What do you think about adding a method like $element->deflated_value
or $element->deflated_default?
moritz
Am 04.02.2008 um 23:02 schrieb Carl Franks:
> On 04/02/2008, Moritz Onken <onken at houseofdesign.de> wrote:
>> Hi,
>>
>> I created a DateTime deflator in the form config file but this
>> deflator isn't called on defaults_from_model. I can't find a deflator
>> call in the source of HTML::FormFu::Model::DBIC. Is supposed to be? I
>> could add the deflator to the dbic table but I prefer the formfu
>> deflator.
>>
>> I could write a patch which calls all the deflators a field has.
>
> Just to check we're on the same page here...
>
> Your DBIC class should be using DBIx::Class::InflateColumn::DateTime -
> which turns your column value into a DateTime object.
>
> Your corresponding FormFu field should be using
> HTML::FormFu::Deflator::DateTime to ensure that the DateTime object
> gets correctly stringified when it's used in your form.
>
> If you're not already using DBIx::Class::InflateColumn::DateTime, you
> shouldn't need to be using a FormFu Deflator.
>
> The FormFu Deflator will only get called when you print (or otherwise
> stringify) your form - specifically, it gets called during
> $element->render_data(), which gets called during $form->render;
>
> This an example of what defaults_from_model() essentially does - (say
> the column is called 'start_time') -
>
> $form->get_field('start_time')->default( $row->start_time );
>
> ...so the deflators shouldn't get called during this stage.
>
> Does that makes things clearer?
>
> Carl
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.rawmode.org
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
More information about the HTML-FormFu
mailing list