Re: Question about QuickForm Renderers

From: Date: Thu, 28 Aug 2003 20:04:13 +0000
Subject: Re: Question about QuickForm Renderers
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-7449@lists.php.net to get a copy of this message
Hi! John Vincent wrote:
I've taken the Default.php from the PEAR renderer directory and copied it into my own include directory. I've now got my form successfully using my template. My problem comes from setting $_groupTemplate within that class. I wanted to have anything that I set as a group to be contained with the <fieldset> tag. Here is what I have currently: /**
    * HTML for the current group
    * @var      string
    * @access   private
    */
    var $_groupTemplate =
        "<fieldset> <legend>My Fieldset</legend>{content}</fieldset>\n\t";
My problem is that no matter what I set in _groupTemplate or _groupElementTemplate, it uses the default element template to render.
1) The problem with private variables is that they are, uh, private. ;] 2) In case the comment "HTML for the current group" does not ring any bells, this template is assigned to in startGroup() method, line 323: $this->_groupTemplate = $this->_prepareTemplate($name, $group->getLabel(), $required, $error);
Some might suggest that I use the set functions but I wanted to have a standardized look and feel for all element groups and save myself coding a set after each group was created.
Yep, laziness is programmers virtue. ;]
Can anyone provide some advice? I'm really enjoying working with QuickForm but this is really my last hurdle to clear. FYI, the task I'm attempting to accomplish works fine with: $renderer->setGroupTemplate("\n\t<fieldset>
                                                <legend>{label}</legend>
                                                {content}
</fieldset>\n\t".'ichkABC'); but as I've said, I use many form groups on a page and really want this to apply to all of them.
You can try hacking line 325 of Default.php: $this->_groupWrap = empty($this->_groupWraps[$name])? '': $this->_groupWraps[$name]; Insert your default template instead of '' here. Or better yet, consider using some template-engine-based renderer.
As an aside, what's the best place to submit a feature request? Following the Element Group as <fieldset>, I'd like to be able to use the group header as the <legend> for the <fieldset>.
Don't quite get you here: what is the group header?

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