[html-formfu] Pre-filling forms

Zbigniew Lukasiak zzbbyy at gmail.com
Thu Feb 7 23:07:10 GMT 2008


On Feb 7, 2008 11:20 PM, Carl Franks <fireartist at gmail.com> wrote:
> On 31/01/2008, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:
> > On Jan 31, 2008 4:10 PM, Moritz Onken <onken at houseofdesign.de> wrote:
> > > you could easily put the params in the default of the form.
> >
> > Sure - but wouldn't it be a bit different then?  Would it work exactly
> > the same way with checking the constraints and for example building
> > the DateTime object out of several parameters?
>
> So you'd still want constraints to be run, even though submitted() is false?
> I think rather than adding yet-another option to formfu
> (pretend_its_submitted()?) and making the logic even more complicated,
> it'd probably be best to do this on the application-side.
>
> The only reason submitted() would be false and the constraints not
> run, is if you've set indicator() to a fieldname that wasn't given.
> If you don't set indicator(), the default  behaviour is that
> submitted() is true if *any* field on the form is present in the
> $query.
>
> Now, you only need to check it was a POST, to decide that it's
> 'really' submitted:
>
> if ( $form->submitted_and_valid && $c->req->method eq 'POST' ) {
>     $form->save_to_model();
> }
>
> Does that give you what you were after?

Ah - yeah - that could work for most of the cases. Unfortunately not
for Facebook applications where every request is a POST - but this
inspired me that I can add another 'indicator' parameter and check it
in that "if". Even though that request does not save the data into the
DB I would rather check the parameters anyway - and I also need to
build a DateTime from them - I would rather not build another deflator
for that.

I had this thought today that the argument about external pages
prefilling the form is not very strong - since it would not be that
difficult for an external page to create a form that would POST the
same information.  But the solution above should work for me.

Cheers,
Zbigniew



More information about the HTML-FormFu mailing list