Re: QuickForm::addRule in groups

From: Date: Tue, 08 Apr 2003 15:32:42 +0000
Subject: Re: QuickForm::addRule in groups
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15040@lists.php.net to get a copy of this message
Bertrand Mansion wrote:
<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));
yeah ok.
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.
ok, i didnt think of that
$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);
i didnt give it a name, because i didnt want this name around the elements name. what a group names does is given the element the name: groupName[elemenName] can i prevent from doing that?
But I don't see why you use a group in that case.
actually just because i get the form via ->toHtml() and the renderer built a table around it, so that the 'html'-element is right above the textarea, it's just and additional info for the textarea, which should be right at this spot Should i do that differently? May use the Array-Renderer and build the form in the template ... mmmh i will think about it
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.
ok, thanks a lot -- Wolfram ... opensource @ vision:produktion ... http://opensource.visionp.de ... translating template engine .... http://sf.net/projects/simpletpl ... authentication system .... http://sf.net/projects/auth

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