Hi Peter,
In my initial post I've written about this option:
> I thought about using ignore_if_empty option, but I lose ability to unset the column value to NULL with it.

thanks for your reply

15.06.2011 13:12, Peter Shangov пишет:
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<tark...@over.ru>
To: html-formfu@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@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu



--
Dmitry Bigunyak
e-mail: ices...@inbox.ru


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to