Re: QuickForm::addRule in groups

From: Date: Tue, 08 Apr 2003 15:05:32 +0000
Subject: Re: QuickForm::addRule in groups
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15038@lists.php.net to get a copy of this message
<wolfram@visionp.de> wrote : > thanks Bertrand. > cas 1) is just what i am doing > > but i think i still have a prob :-( > i do the following > > $group = array(); > $group[0] =& HTML_QuickForm::createElement('html','Please....'); > $group[1] =& > HTML_QuickForm::createElement('textarea','newData[comment]'); > $group[1]->setRows(10); > $group[1]->setCols(60); > $group[1]->setValue(@$data['comment']); > $el =& $form->addGroup($group,null,'Comment'); First, why don't you use directly this : $form->addElement('textarea', 'newData[comment]', 'Please....', array('rows' => 10, 'cols' => 60)); BTW, use setDefaults() if your $data['comment'] value is supposed to be the default value of your textarea: $form->setDefaults(array('newData[comment]' => $newData['comment'])); There is no need to use setDefault if it's the submitted value as it is automatically retrieved. So just don't specify a value. > $rule[0][1] = array('Please provide the comment!', 'required'); > $form->addGroupRule($el->getName(),$rule); You MUST give your group a name. Do $form->addGroup($group, 'groupname', 'Comment'); and $form->addGroupRule('groupname', $rule); But I don't see why you use a group in that case. Groups are here for logical reasons, not for presentation or layout reasons.. You can have a look at the different examples in the docs/ directory. Example7 deals with grouped elements. Bertrand Mansion Mamasam > but the renderer::renderElement() doesnt tell me it's required. > > and i looked into group.php and the method > HTML_QuickForm/group::accept() > doesnt say it is required, so when calling > $element->accept($renderer, $required); > it doesnt pass the $required is false :-( > > am i doing something wrong? > > thanks

« previous php.pear.dev (#15038) next »