views:

216

answers:

0

I want to create a display group generated from foreach() clause output. I can't seem to get the syntax correct.

Here's the business logic:

for each category row
find the associated fees
output the category description as a label
and the fees as radio buttons
then create a display group with the fees as the group elements
and the category description as the legend.

I then have a style sheet format the elements on the page.

and here's the code:

foreach ($categoryData as $categoryRow) {
    $fees[$i] = new Zend_Form_Element_Radio("fees[$i]");
    $fees[$i]->setDescription(strval($categoryRow['description']));

    foreach ($feeData as $feeRow) {
        if ($feeRow['categories_idCategory'] == $categoryRow['idCategory']){
            $fees[$i]
                ->addMultiOption($feeRow['idFees'] . '-' . $feeRow['categories_idCategory'], $feeRow['amount'] . '-' . $feeRow['name']);
        }
    }
    $fees[$i]->setRequired(TRUE);
    $this->addElements(array($fees[$i]));
    $this->addDisplayGroup($feeRow['name'], 'feeGroup',array('legend' => strval($feeRow['description'])));
    $i++;
}

I tried placing the addDisplayGroup() code within the foreach(), but I get the error:

Message: No valid elements specified for display group

So, my guess is that I'm making some kind of novice mistake that you experts will spot right away. I appreciate your time and attention to this matter.