logo       

Re: Problems with subForms: msg#00188

php.zend.framework.mvc

Subject: Re: Problems with subForms

-- Axel Wüstemann <awu-oRH8NxEK794@xxxxxxxxxxxxxxxx> wrote
(on Thursday, 31 July 2008, 03:42 AM -0700):
> For an event registration I need a registration form n-times, as n is the
> count of sessions or subevents of a main event.

<snip>

> Then I create an empty form with Zend_Form and add the n SubForms to it:
>
> foreach($aSessions as $aSession) {
> $oForm->addSubForm($oSubForm, 'session_'.$aSession['EVENT_ID']);
> }
>
> What I get ist: all Subforms will have the same Id:

You need to clone the sub form in each iteration; otherwise, the same
object is used, so whichever sub form name is registered last wins. Try
this instead:

foreach($aSessions as $aSession) {
$clone = clone $oSubForm;
$oForm->addSubForm($clone, 'session_'.$aSession['EVENT_ID']);
}

--
Matthew Weier O'Phinney
Software Architect | matthew-C1q0ot2/XZ0@xxxxxxxxxxxxxxxx
Zend Framework | http://framework.zend.com/



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise