[html-formfu] Model::DBIC inserts empty strings instead of NULL values

Peter Shangov pshangov at yahoo.com
Wed Jun 15 09:12:02 GMT 2011


Dmitry, Alex,

There is an undocumented option 'ignore_if_empty' for columns, which instructs HTML::FormFu::Model::DBIC not to save the value to the database if it is an empty string. Can you try that and see if it works? Here is a sample configuration:

elements:
  - type: Text

    name: some_field
    model_config:
        ignore_if_empty: 1

Cheers,

--
Peter



----- Original Message -----
> From: Alex Povolotsky <tarkhil at over.ru>
> To: html-formfu at lists.scsys.co.uk
> Cc: 
> Sent: Monday, 6 June 2011, 12:04
> Subject: Re: [html-formfu] Model::DBIC inserts empty strings instead of NULL values
> 
> On 04/28/11 17:52, Dmitry Bigunyak wrote:
>>  Thanks for your reply, I'm not alone :)
>>  As a temporary solution I've blocked updating on new versions. Hope 
> Carl will reply in that subject.
> 
> I've patched model
> 
> __PACKAGE__->load_components(qw( FilterColumn ));
> foreach my $bool ( qw(default_read default_write default_edit) ) {
>     __PACKAGE__->filter_column($bool => {
>         filter_to_storage => sub { ($_[1] eq '')?undef:$_[1] }
>                                });
> }
> 
> 
> It's ugly as hell, but it works fine and replace empty string with undef.
> 
> Alex
> 
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>



More information about the HTML-FormFu mailing list