OK, I answered my own question by searching through the mailing list
archive in my email. I'd link to it but I can't find it in Nabble for
some reason but it was a post by Amr Mostafa on Jun 7, 2008. I
extended Zend_Form_SubForm to create something like this:

class My_SubForm extends Zend_Form_SubForm
{
    protected $_label;

    public function setLabel($label)
    {
        $this->_label = $label;
        return $this->_label;
    }

    public function getLabel()
    {
        return $this->_label;
    }

    public function isRequired()
    {
        return false;
    }

    public function loadDefaultDecorators()
    {
        parent::loadDefaultDecorators();
        $this->removeDecorator('DtDdWrapper');
        $this->addDecorator('Label', array('tag' => 'dt'));
    }
}

Then, in my form code (since I've now got a setLabel method):

        $phoneSubForm = new My_SubForm();
        $phoneSubForm->setLabel('Phones');
        $this->addSubForm($phoneSubForm, 'phone');

Which gets me (mostly) what I want:

<dt><label for="phone" class="optional">Phones</label></dt>
<fieldset id="fieldset-phone"><dl>...

This leaves me with a label that doesn't actually tie back to any form
element (hence, I'm guessing, the reason why the default
implementation of SubForm doesn't use label, but fieldset and "legend"
instead).

Thanks,
Bradley

On Fri, Dec 5, 2008 at 7:09 PM, Bradley Holt <[EMAIL PROTECTED]> wrote:
>
> I have a SubForm that and I'd like to set the content of its related dt. This 
> is the first part of what I'm currently getting:
>
> <dt>&nbsp;</dt><dd><fieldset id="fieldset-phone"><dl>...
>
> What I want to do is replace the "&nbsp;" above with the word "Phones". It 
> appears that there is no setLabel on SubForms like there is on form elements. 
> There is a setLegend but that does not affect the dt, it only adds a legend 
> element:
>
> <dt>&nbsp;</dt><dd><fieldset id="fieldset-phone"><legend>Phones</legend>
> <dl>...
>
> My guess is that I need to get a reference to the DtDdWrapper decorator and 
> set an option on that. However, I'm not sure what option(s) I'd use:
>
>         $phoneSubForm->getDecorator('DtDdWrapper')->setOption('?', 'Phones');
>
> Is this possible and if so am I going about it all wrong?
>
> Thanks,
> Bradley
>
> --
> Bradley Holt
> [EMAIL PROTECTED]
>



--
Bradley Holt
[EMAIL PROTECTED]

Reply via email to