ToonMariner Posted June 3, 2010 Share Posted June 3, 2010 Hi peeps. In need of a bit of assistance with zend form... I need to create a form with multicheckbox and have a text box associated with that checkbox. I can handle to output but its building the form itself - the mark up needed would be something like <form> <dl> <dt></dt> <dd> <label><input type="checkbox" name="id[]" id="id-1" value="1" />Text 1</label> <label for="text-1">Title:</label><input type="text" name="text[]" id="text-1" /> <br /> <label><input type="checkbox" name="id[]" id="id-2" value="2" />Text 2</label> <label for="text-2">Title:</label><input type="text" name="text[]" id="text-2" /> </dd> </dl> </form> I've not got to custom decorators or view helpers yet but suspect that this is a case where I'm gonna need it. ANy help would be very much appreciated... Quote Link to comment https://forums.phpfreaks.com/topic/203709-zend-form/ Share on other sites More sharing options...
ignace Posted June 3, 2010 Share Posted June 3, 2010 $form->addElement('Checkbox', 'id', array('isArray' => true)); $form->addElement('Text', 'text', array('isArray' => true)); Quote Link to comment https://forums.phpfreaks.com/topic/203709-zend-form/#findComment-1067109 Share on other sites More sharing options...
ToonMariner Posted June 3, 2010 Author Share Posted June 3, 2010 Thanks ignace... Yeah I can see how that is going to work... Any chance of an example of how you would get the form rendered like in my example? I need the text box to be implicitly associated with its corresponding checkbox within the markup.. Apologies for noobieness liking this framework a lot and picking bits up quickly but this one is a bit beyond me right now. Quote Link to comment https://forums.phpfreaks.com/topic/203709-zend-form/#findComment-1067169 Share on other sites More sharing options...
ToonMariner Posted June 4, 2010 Author Share Posted June 4, 2010 As an appendage to that last post... Is it possible to get zend from to render array type elements alternating fasion? so in the case of $form->addElement('Checkbox', 'id', array('isArray' => true)); $form->addElement('Text', 'text', array('isArray' => true)); it could output <input type="checkbox" name="id[]" /><input type="text" name="text[]" /> <input type="checkbox" name="id[]" /><input type="text" name="text[]" /> <input type="checkbox" name="id[]" /><input type="text" name="text[]" /> <input type="checkbox" name="id[]" /><input type="text" name="text[]" /> Quote Link to comment https://forums.phpfreaks.com/topic/203709-zend-form/#findComment-1067699 Share on other sites More sharing options...
ignace Posted June 4, 2010 Share Posted June 4, 2010 Thanks ignace... Yeah I can see how that is going to work... Any chance of an example of how you would get the form rendered like in my example? I need the text box to be implicitly associated with its corresponding checkbox within the markup.. Apologies for noobieness liking this framework a lot and picking bits up quickly but this one is a bit beyond me right now. Tell your form not to auto-load it's default decorators. Then write your custom decorators and add them. Look at the API for more information till' now I never needed to use custom decorators. Quote Link to comment https://forums.phpfreaks.com/topic/203709-zend-form/#findComment-1067747 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.