php - Set default radio button in Cakephp -


the below code creates radio buttons , html go them, works want set first radio button default selected 1 , im not sure needs added.

<?php      ($i =0; $i < count($packages); $i++){        echo "<div class='package-outter'>";        echo "name: ".$packages[$i]['package']['name']."<br>";        echo "number of campaigns (per month): ".$packages[$i]['package']['quantity']."<br>";        echo "price: ".$packages[$i]['package']['price']."<br>";           if ($i == 0){            echo $this->form->input('package', array(                                    'type' => 'radio',                                    'options' => array($packages[$i]['package']['id'] => $packages[$i]['package']['name'],),                                    'class' => 'testclass',                                     ));          }else{            echo $this->form->input('package', array(                                    'type' => 'radio',                                    'options' => array($packages[$i]['package']['id'] => $packages[$i]['package']['name'],),                                    'class' => 'testclass',                                    'hiddenfield' => false, // added non-first elements                                     ));           }             echo "</div>";           }  ?> 

i'm not familiar cakephp quick google search gave me this

$options = array(     'standard' => 'standard',     'pro' => 'pro' );  $attributes = array(     'legend' => false,     'value' => $foo );  echo $this->form->radio('type', $options, $attributes); 

so should add attribute 'value' , set default selected radio


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -