rafapas22 Posted July 13, 2016 Share Posted July 13, 2016 (edited) Buenas a todos. Estoy intentando marcar como checked una de las opciones del radio button pero no encuentro el parámetro adecuado, como lo hago? Si por ejemplo, siguiendo como ejemplo el código de abajo, quisiera poner como marcado por defecto el id del radio button 'active_off' como lo haria? Gracias por adelantado. array( 'type' => 'radio', // This is an <input type="checkbox"> tag. 'label' => $this->l('Enable this option'), // The <label> for this <input> tag. 'desc' => $this->l('Are you a customer too?'), // A help text, displayed right next to the <input> tag. 'name' => 'active', // The content of the 'id' attribute of the <input> tag. 'required' => true, // If set to true, this option must be set. 'class' => 't', // The content of the 'class' attribute of the <label> tag for the <input> tag. 'is_bool' => true, // If set to true, this means you want to display a yes/no or true/false option. // The CSS styling will therefore use green mark for the option value '1', and a red mark for value '2'. // If set to false, this means there can be more than two radio buttons, // and the option label text will be displayed instead of marks. 'values' => array( // $values contains the data itself. array( 'id' => 'active_on', // The content of the 'id' attribute of the <input> tag, and of the 'for' attribute for the <label> tag. 'value' => 1, // The content of the 'value' attribute of the <input> tag. 'label' => $this->l('Enabled') // The <label> for this radio button. ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), Edited July 13, 2016 by rafapas22 (see edit history) Link to comment Share on other sites More sharing options...
buhoplace Posted July 13, 2016 Share Posted July 13, 2016 Hola, probaste lo que vimos antes? $this->fields_value=array( 'active'=>true (o false) ); Link to comment Share on other sites More sharing options...
rafapas22 Posted July 14, 2016 Author Share Posted July 14, 2016 Pero con esa opción se marca la última opción del radio button, si yo quiero marcar por ejemplo el id=> 'active_on' que es parte del name=> 'active' como lo hago? me falta saber cómo marcar un elemento especifico del radio button Link to comment Share on other sites More sharing options...
buhoplace Posted July 14, 2016 Share Posted July 14, 2016 El id solo le da un nombre al id del elemento del html que vas a crear <input type="radio" name="raddiobuttons" id="active" value="2"></label> para decirle cual queremos activar, usaremos el name-> raddiobuttons, podemos poner más de 2 radiobuttons $this->fields_value=array( 'raddiobuttons'=>0/1/2 ); array( 'type' => 'radio', 'label' => $this->l('Row'), 'name' => 'raddiobuttons', 'required' => true, 'values' => array( array( 'id' => 'active', 'value' => 1, 'label' => $this->l('1') ), array( 'id' => 'active', 'value' => 0, 'label' => $this->l('0') ), array( 'id' => 'active', 'value' => 2, 'label' => $this->l('2') ) ) ), Link to comment Share on other sites More sharing options...
rafapas22 Posted July 14, 2016 Author Share Posted July 14, 2016 ok, perfecto. Gracias Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now