I figured it out, it's the set-method of the model class that does the
following:
if ($v !== null && !is_int($v) && is_numeric($v)) { $v = (int) $v; }
If it receives an empty value (int) $v will return 0. I added this and
everything works:
if ( $v == 0 ) { $v = null; }
On Jul 26, 4:33 pm, Kiril Angov <[EMAIL PROTECTED]> wrote:
> So is your problem that the admin generator saves a '0' in the database
> or because if you leave the field empty the validator YML files you have
> set does not let you save you form because sfNumberValidator returns '0'
> as an error input?
>
> If it is the first case then you can overwrite the save() method of the
> method class and if the value is '0' just 'return' and do not save
> otherwise call 'parent::save($v, $conn)'
>
> Now when I think about it it cannot be the second case as you will use
> an input field for the html and there there is no default value that you
> will not be able to see clearly.
>
> Maybe too confusing reply but hope you will get the idea.
>
> Kupo
>
> Daniel Staver wrote:
> > No, there is no default value in the database. If I store directly to
> > the database without using the admin generator and without specifying
> > a value for the field I get the correct behaviour, no value is stored.
> > If I save through the admin generator without specifying a value, 0 is
> > stored.
>
> > On Jul 26, 1:40 pm, Haris Zukanovic' <[EMAIL PROTECTED]> wrote:
>
> >> Is 0 the default value for the field in your database ?
>
> >> Daniel Staver wrote:
>
> >>> When I leave an integer field blank in a form generated by the admin
> >>> generator the actual value stored in the database is 0.
>
> >>> However, this breaks validation with the sfNumberValidator as the
> >>> permitted values for this particular field is a nubmer between
> >>> 1960-2020 if a number is entered. Is there a way to change this so
> >>> that it doesn't try to store the value 0 when the field is actually
> >>> blank?
>
> >>> If I try to create this object directly with propel it's stored as
> >>> expected, I only run into the problem when I save through the admin
> >>> generator.
>
> >> --
> >> Haris Zukanovic
> >> CEO
> >> Software development and research
> >> International Business Development, SOFTING ltd.
>
> >> office +387 36 318 339
> >> GSM +387 61 839 069
>
> >>http://www.eu-softing.com
>
> >> CONFIDENTIALITY NOTICE
> >> This e-mail and any attached files, sent by a company e - mail system,
> >> contains company confidential and/or privileged information and is
> >> intended only for the person or entity to which it is addressed and only
> >> for the purposes therein set forth. If you are not the intended recipient
> >> (or have received this e-mail in error) please notify the sender
> >> immediately and destroy this e-mail. Any unauthorized copying, disclosure,
> >> distribution or other use of, or taking of any action in reliance upon,
> >> the material in this e-mail by persons or entities other than the intended
> >> recipient is strictly forbidden.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---