On Dec 14, 2007 2:07 AM, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> On 13.12.2007 14:03 John Siracusa wrote:
> > On Dec 13, 2007 4:24 AM, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> >> When I create a record with such a field, it is usually NULL but
> >> after some editing with the help of RHTMLO the empty field value could
> >> become '' when saved.
> >
> > I believe the latest release of Rose::HTML::Objects fixed this bug for
> > Numeric fields.  That is, you should get undef for an empty Numeric
> > field instead of an empty string.  Does this bug exist in other field
> > types as well?
>
> I didn't install the latest version yet but this is what I get with a
> text field:
> 1. set a field 'anrede2' to NULL with the sqlite3 command line
> 2. edit the record with RHTMLO without touching 'anrede2'
>    Here is the form/field definition:
>    anrede2 => {type => 'text', class => 'normfield'},
>    linked to RDBO with init_with_object/object_from_form
> 3. After $obj->save I check again at the command line and it is ''

I changed the Numeric field type to convert empty string input into an
undef internal value because an empty string isn't a valid numeric
value.  But in the case of a text field, an empty string is a valid
string value.

I think your problem is at a level higher: it's the thing feeding your
params() to the form.  If you've decided that an empty text field
should result in an undef field value, then the piece of code you have
that converts from a query string like "a=&b=&c=123" to a hashref
suitable for feeding into $form->params() should simply take any query
parameter that has no value (i.e., a and b in the query string above)
and set it to undef in the hash.

That is, given this query string:

    a=&b=&c=123

Your current hashref being fed to $form->params() looks like this:

    { a => '', b => '', c => 123 }

but you should make it look like this instead:

    { a => undef, b => undef, c => 123 }

-John

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to