Re: timeOptions and dateOptions methods for FormBuilder :)

From: Date: Tue, 10 May 2005 17:17:05 +0000
Subject: Re: timeOptions and dateOptions methods for FormBuilder :)
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19148@lists.php.net to get a copy of this message
On 5/9/05, pear@electroteque.org <pear@electroteque.org> wrote: > Ok for the life i me i couldnt find these in the docs, I had to sift > through the API luckily its in PHP :) > > I now have my time and dates with emptyoptions which are set as NULL, as it > was causing alot of issues, especially when i was to use it for searching > (required not null fields i'll get to in a sec). > > Here is how i did it. > > in the do > > function timeOptions(){return array('addEmptyOptions'=>true);} > > Now my big question, how can i set global for a certain page that no fields > are required especially for not null fields. This is important for a search > form where i want to build the entire form but only make a few fields as > required. I'll be going through the code if it requires tweaking ... > This isn't possible. However, if you had looked at my Frontend code... You can quite easily stop all rules using this: $form->_rules = array(); $form->_formRules = array(); $form->_required = array(); Granted, this is technically editing private vars, but oh well. You can also stop the required rules by removing the NOT NULL bit from the types. class My_DO extends DB_DataObject { //.... var $_searchForm = false; function table() { $table = parent::table(); if ($this->_searchForm) { foreach (array_keys($table) as $key) { $table[$key] = $table[$key] & ~DB_DATAOBJECT_NOTNULL; } } return $table; } } -- Justin Patrin

« previous php.pear.general (#19148) next »