Grouping switches in the Zend Framework

I want to introduce switches in logical product groups:

Broadband products: (*) 2 Mbit ( ) 4 Mbit Voice products: ( ) Standard ( ) Total Bundles: ( ) 4 Mbit + Standard ( ) 4 Mbit + Total 

All radio buttons have the same name attribute - you get the idea. It seems that Zend Framework 1.8 does not support switch grouping in this way. Is there any solution for this?

Update . To clarify, as a result, the code should look like this:

 Broadband products: <br/> <input type="radio" name="product" value="1"/> 2 Mbit <br/> <input type="radio" name="product" value="2"/> 4 Mbit <br/> Voice products: <br/> <input type="radio" name="product" value="3"/> Standard <br/> <input type="radio" name="product" value="4"/> Total <br/> Bundels: <br/> <input type="radio" name="product" value="5"/> 4 Mbit + Standard <br/> <input type="radio" name="product" value="6"/> 4 Mbit + Total <br/> 

Do not pay attention to the exact formatting code. There are only form elements.

+7
php radio-button zend-framework
source share
3 answers

You are correct that ZF 1.8 does not support grouping options in this way. You can easily view the code inside Zend_View_Helper_FormRadio and create your own view helper that supports a multidimensional array (i.e. Selected Groups). I should have done this already for the project, see an example at pastebin.com

PHP:

 $form->addElement('radio', 'test', array( 'helper'=>'formMultiRadio', 'label'=>'Test Thing', 'multiOptions'=>array( 'Test'=>array('1'=>'1', '2'=>'2'), 'Test 2'=>array('3'=>'3', '4'=>'4'), 'Test 3'=>array('5'=>'5', '6'=>'6'), ), )); 

HTML Result:

 <dt id="test-label"><label for="test" class="optional">Test Thing</label></dt> <dd id="test-element"> Test<br /> <label for="test-1"><input type="radio" name="test" id="test-1" value="1" />1</label><br /> <label for="test-2"><input type="radio" name="test" id="test-2" value="2" />2</label><br /> Test 2<br /> <label for="test-3"><input type="radio" name="test" id="test-3" value="3" />3</label><br /> <label for="test-4"><input type="radio" name="test" id="test-4" value="4" />4</label><br /> Test 3<br /> <label for="test-5"><input type="radio" name="test" id="test-5" value="5" />5</label><br /> <label for="test-6"><input type="radio" name="test" id="test-6" value="6" />6</label> </dd> 
+12
source share
0
source share

I recently wrote my own item for archiving it. Check out here http://paveldubinin.com/2011/04/zend-form-radio-buttons/

0
source share

All Articles