unrequired fields

A place for users and developers of the Xataface to discuss and receive support.

unrequired fields

Postby gstarke » Sat May 22, 2010 2:27 am

Hi
I am just beginning and have been experimenting with validation in fields.
I had assumed that, as it was stated that the default for text fields was "required", and many in my database do not need to be, that I could script it out by saying "validators:required = false" for those that were NOT required, but this does not seem to work. How can I operate the Save if many fields are allowed to remain blank in my DB?
gstarke
 
Posts: 10
Joined: Tue May 11, 2010 2:38 am

Re: unrequired fields

Postby shannah » Sat May 22, 2010 11:28 am

The best way to make a field not required is to make it allow null values in the mysql field definition. Fields that are defined as NOT NULL are required by default. Right now there is a bug that seems to prevent setting validators:required=0 to turn of required so if you need the field to be NOT NULL but don't want it to be required (you should have a good reason), then you'd have to do this programmatically in the init() method of the delegate class:

Code: Select all
function init(&$table){
    $fld =& $table->getField('myfield');
    unset($fld['validators']['required']);
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 27 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved