unrequired fields

Archived from the Xataface Users forum.

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?


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']); }