> Can you show us the HTML code for the form including the radio buttons
> and the hidden field you mention, and also could you supply the PHP
> you are using to create the form?

> Can you show us the HTML code for the form including the radio buttons
> and the hidden field you mention, and also could you supply the PHP
> you are using to create the form?
Sure thing. In my "add" action:
                $this->set('user', $this->user);
                $underwear_types = 
$this->EdibleUndy->UnderwearType->find('all');
                $this->set(compact('underwear_types'));

Because I want to get all the fields in UnderwearType (id, name AND
image), I am doing passing 'all' to find instead of 'list'.

Then, in the view, since I want to customize the output of radio
buttons, I loop though the array and specify a single option each
time. Here's the view snippet:

<?
                echo $form->create('EdibleUndy', array('url'=>$appCallbackUrl .
"/" . $this->params['url']['url'])); //
                echo '<table class="undietypes">';
                        echo '<tr>';
                                foreach($underwearTypes as $type){
                                echo '<td>';
                                        echo $form->input('underwear_type_id', 
array('type'=>'radio',
                                                                                
                                                 'legend'=>false,
                                                                                
                                                 'label'=>'',
                                                                                
                                                 'div'=>false,
                                                                                
                                                 
'options'=>array($type['UnderwearType']['id']=>'')));

                                        echo '<h2>' . 
$type['UnderwearType']['name'] . '</h2>';
                                        echo $html->image($appCallbackUrl . 
'img/' . $type
['UnderwearType']['image']);
                                echo '</td>';
                                }
                        echo '</tr>';

                        echo '<tr>';
                                echo '<td colspan=4>';
                                        echo $form->submit('Select', array
('type'=>'submit','div'=>'submit_container'));
                                echo '</td>';
                        echo '</tr>';
                echo '</table>';


                echo $form->end();
        ?>

The resulting HTML output is this:

<form method="post" action="http://www.mydomain.com/underwear/undies/
add">
        <fieldset style="display:none;">
        <input type="hidden" name="_method" value="POST" />
        </fieldset>
    <table class="undietypes">
        <tr>
                <td>
                <input type="hidden" name="data[EdibleUndy]
[underwear_type_id]" id="EdibleUndyUnderwearTypeId_" value="" />
                <input type="radio" name="data[EdibleUndy]
[underwear_type_id]" id="EdibleUndyUnderwearTypeId1" value="1"  />
                <h2>Boxers</h2>
                <img src="http://www.mydomain.com/edible_underwear/img/
boxers.gif" alt="" />
                        </td>
            <td>
                <input type="hidden" name="data[EdibleUndy]
[underwear_type_id]" id="EdibleUndyUnderwearTypeId_" value="" />
                <input type="radio" name="data[EdibleUndy]
[underwear_type_id]" id="EdibleUndyUnderwearTypeId2" value="2"  />
                <h2>Briefs</h2>
                <img src="http://www.mydomain.com/edible_underwear/img/
briefs.gif" alt="" />
            </td>
            <td>
                <input type="hidden" name="data[EdibleUndy]
[underwear_type_id]" id="EdibleUndyUnderwearTypeId_" value="" />
                <input type="radio" name="data[EdibleUndy]
[underwear_type_id]" id="EdibleUndyUnderwearTypeId3" value="3"  />
                <h2>Panties</h2>
                <img src="http://www.mydomain.com/]/edible_underwear/
img/panties.gif" alt="" />
                        </td>
                </tr>
        <tr>
            <td colspan=4>
                <div class="submit_container"><input type="submit"
type="submit" value="Wear" /></div>
            </td>
        </tr>
    </table>
</form>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to