[html-formfu] Default Values

Carl Franks fireartist at gmail.com
Tue Apr 17 14:41:27 GMT 2012


On 17 April 2012 14:33, Robyn Jonahs <learn.catalyst at gmail.com> wrote:
> Hi,
>
> I am using Catalyst 5.90011 with HTML::FormFu::Model::DBIC and mysql
>
> I am having a problem where I can't get the default value set in mysql and
> also in my Catalyst Schema::Result to get inserted into the database. It
> sticks
> a null value in rather than my default value. For example, this is a
> checkbox
>
> In the Schema::Result::File.pm
>
>   "trip",
>   { data_type => "tinyint", default_value => 0, is_nullable => 1 },
>
> In the YAML form definition
>     # Trip?
>     - type: Checkbox
>       name: trip
>       label: Trip Expense?
>
> I get an empty checkbox with a new form, but if I don't check it, then it
> gets set in the database as Null
>
> If I check it and uncheck it, it gets put into the database as Null
>
> If I check it, it gets put in the database as 1
>
> Why won't it insert the default value of 0?

I think this would be fixed by either setting the DBIC column to
is_nullable => 0
or by adding a "default: 0" to the formfu element definition.

If you don't want to change is_nullable, and the "default: 0" alone
doesn't work, try also adding "retain_default: 0" - it's been a long
time since I've used this stuff, and can't remember all the details.

Carl



More information about the HTML-FormFu mailing list