RE: [PEAR] QuickForm - either choose value from option-select or type in value in textbox

From: Date: Fri, 16 Apr 2004 08:21:53 +0000
Subject: RE: [PEAR] QuickForm - either choose value from option-select or type in value in textbox
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11902@lists.php.net to get a copy of this message
Hi! OK - so you basically look fort he rule? Or what is your problem now? Here is what I use. I did not have the time to also create a JS method and finally decided to make my whole project without JS validations - but you are welcome to dig into it and create one. And it is also old style validation. But it works ... $this->registerRule('checkmax', null, 'RuleCheckMax'); $this->addRule('groupname', 'Caption', 'checkmax', array('max'=>1)); function checkMax($elementName, $array, $max) { $count=0; foreach ($array as $key=>$value) if ($value!='') $count++; if ($count>$max) return false; else return true; } } You could also use a textfield with a Button to add the text directly to the input array with JS (I've seen this somewhere - I guess on Selfhtml for all Germans) but I guess this will be very hard to get to work with QF because you need to provide your own way to submit all the added values because the hash of value=>name of a selectbox is usually not submitted and so your selectbox will need a way to get to know them. Regards Daniel

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