[html-formfu] constraints_from_dbic: when to call?

Carl Franks fireartist at gmail.com
Fri Mar 13 17:03:49 GMT 2009


2009/3/13 Ian Wells <ijw at cack.org.uk>:
> In my edit function in a Catalyst controller, I have:
>
> sub edit :Local :FormConfig :Args(1) {
>
> [...]
>
>    $form->constraints_from_dbic($table);
>
>    if ($form->submitted_and_valid) {
>        $form->model->update($row);
>
> But the DB crashes out with an overly-long string - which it
> shouldn't, since the form should trap that and report it.  T
>
> he constraints are created in the form datastructure, but FormFu
> hasn't spotted the length violation.  Should I be setting them earlier
> or something?

You need to call $form->process() after constraints_from_dbic()

submitted_and_valid() only reports the result of the last process() -
which was called by Catalyst-Controller-HTML-FormFu, before you'd
added the constraints.

Carl



More information about the HTML-FormFu mailing list