Re: QuickForm::addRule in groups

From: Date: Tue, 08 Apr 2003 13:26:32 +0000
Subject: Re: QuickForm::addRule in groups
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15024@lists.php.net to get a copy of this message
Wolfram Kriesing wrote:
if i add a rule for an element in a group, the _required is not passed on to the group, am i right? therefore the renderer doesnt see that the element (in the group) is required I am using the latest CVS version (which becomes v3, I guess) i.e. this $group[0] = HTML_QuickForm::createElement('html','info text'); $group[1] = HTML_QuickForm::createElement('textarea','input','input'); $form->addRule($group[1]->getName(),'This is required!','required'); and in the Renderer (i use an customized version of the Default-Renderer) renderElement() doesnt get the paramter $required=true passed to it. I think the bug is in QuickForm::addRule()
        if ($type == 'required' || $type == 'uploadedfile') {
            $this->_required[] = $element;
        }
should be
        if ($type == 'required' || $type == 'uploadedfile') {
        if ($this->isInGroup($element)) {
                $groupName = $this->getGroup($element);
        $this->_group[$groupName]->setRequired($element);
            } else {
                $this->_required[] = $element;
            }
        }
i am not an QuickForm-Expert. And i dont know if there are methods such as
    isInGroup()
    getGroup()
etc. What do you say? Is there a reason for not using addGroupRule ?
Jeroen

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