Zend: addDisplayGroup() – Setting the legend

Original Code:

$nok = $this->addDisplayGroup(array(‘nok_forename’,'nok_surname’,'nok_day’,'nok_month’,'nok_year’,
‘nok_address1′,’nok_address2′,’nok_town’,'nok_county’,'nok_postcode’,'nok_country’),
‘nextofkin’);

I then set about trying to get a legend on the fieldset that was created. My first thought was:

$nok->setLegend(‘Next of Kin’);

But on second thoughts that would never work. I then remembered that the third variable is normally options passed in an array. So…

$nok = $this->addDisplayGroup(array(‘nok_forename’,'nok_surname’,'nok_day’,'nok_month’,'nok_year’,
‘nok_address1′,’nok_address2′,’nok_town’,'nok_county’,'nok_postcode’,'nok_country’),
‘nextofkin’,array(‘legend’=>’Next of Kin’));

This works. :)

Leave a Reply