Question

My cakephp code for making a select tag is

<?php echo $this->Form->select('User.country_id',array($countries),null,array('id'=>'selection','empty'=>null,'label'=>false,'style'=>'width:231px'));?>

Here I defined id='selection' but when I inspect this dropdown box in browser it is showing id='UserCountryId'. How is that happening? My jquery and javascript is not working because of this.

Was it helpful?

Solution

if u need Id use cake php syntax

<?php
echo $this->Form->input('User.country_id', array(
    'type'=>'select, 
    'id'=>'selection',
    'style'=>'width:231px'
));
?>

your jquery and javascript will work try this

OTHER TIPS

I think your syntax is incorrect. It should be:

<?php
    echo $this->Form->input('User.country_id', array(
        'type'=>'select,
        'options'=>array($countries), // this is probably not needed 
        'id'=>'selection',
        'empty'=>null,
        'label'=>false,
        'style'=>'width:231px'
    ));
?>

You can use following code

<?php 

echo $this->Form->input('User.country_id',array('type'=>'select','options'=>$countries,'id'=>'selection'));

?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top