Powered by Invision Power Board



  Reply to this topicStart new topicStart Poll

> Assigning Class or ID to Form Radio Label, Assigning Class or ID to Form Radio Labe
bluesclues9
Posted: Feb 23 2012, 06:52 PM
Quote Post


Member
**

Group: Members
Posts: 11
Member No.: 2721
Joined: 3-March 11



Hi:
I am completely lost with this.

I am using Form helper in CakePHP and embedded a Radio input into it. The problem is that I need to set either class or id property for the label next to Radio to control it using css.

My code looks like this.
<?php
$contract_type_options = array("Contract" => "Contract", "Remnant" => "Remnant");
echo $this->Form->input('Agreement.contracttype', array('type' => 'radio', 'id' => 'idContractType', 'class' => 'classContractType', 'div' => false, 'options' => $contract_type_options));
?>

and the generated HTML looks like this:

<input type="hidden" name="data[Agreement][contracttype]" id="idContractType_" value="">
<input type="radio" name="data[Agreement][contracttype]" id="IdContractTypeContract" class="classContractType" value="Contract">
<label for="IdContractTypeContract">Contract</label>
<input type="radio" name="data[Agreement][contracttype]" id="IdContractTypeContract" class="classContractType" value="Remnant">
<label for="IdContractTypeContract">Remnant</label>

What I am looking for is to have a class and/or id assigned to those "<label for="IdContractTypeContract">Contract</label>" like <label for="IdContractTypeContract" class="classRadioLabel">Contract</label>

What am I doing wrong here? Please help...I am going nuts with this.

-BC
PMEmail Poster
Top
Vapour0
Posted: Feb 23 2012, 09:34 PM
Quote Post


Advanced Member
***

Group: Members
Posts: 43
Member No.: 3251
Joined: 2-December 11



PHP Code
<?php
echo $this->Form->input('User.name', array(
    
'label' => array(
        
'class' => 'thingy',
        
'text' => 'The User Alias'
    
)
));
?>


That should help.

Just assign the label as an array, then add 'class' or 'id' keys.
And Text for the display text.
PMEmail Poster
Top
bluesclues9
Posted: Feb 23 2012, 09:44 PM
Quote Post


Member
**

Group: Members
Posts: 11
Member No.: 2721
Joined: 3-March 11



Hi
This is what I normally do for all input types. However, this doesn't work for Radio button inputs. The label specifications are completely ignored.

-BC
PMEmail Poster
Top
Vapour0
Posted: Feb 23 2012, 10:05 PM
Quote Post


Advanced Member
***

Group: Members
Posts: 43
Member No.: 3251
Joined: 2-December 11



What about this?

PHP Code
<?php
$contract_type_options 
= array("Contract" => "Contract""Remnant" => "Remnant");
echo 
$this->Form->radio('Agreement.contracttype'$contract_type_options, array(
    
'label' => array('class'=>'this''text' => 'that')
)); 
?>


Does that work? Using 3 parameters and $this->Form->radio( $1, $2, $3 )
PMEmail Poster
Top
bluesclues9
Posted: Feb 24 2012, 03:35 AM
Quote Post


Member
**

Group: Members
Posts: 11
Member No.: 2721
Joined: 3-March 11



Hi, thanks for the response. I tried. The label just shows up like this.
label attribute settings are ignored on label.

<input type="radio" name="data[Agreement][contracttype]" id="AgreementContracttypeContract" value="Contract">
<label for="AgreementContracttypeContract">Contract</label>
PMEmail Poster
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Disclaimer:
This forum is in no way affiliated with the Cake Software Foundation
The CakePHP name and icon is a trademark of the Cake Software Foundation


Lo-Fi Version