Issue
I need to change cakephp default value from select box.Here in controller I have coded
$madDivisions = $this->MadStore->MadDivisions->find('list');
In view
<?php
echo $this->Form->input('mad_divisions_id',array( 'label' => false, 'class'=>'form-control','id'=>'select' ));
?>
After add jquery val() method
<script>
$('#select').change(function(){
var a=$('#select').val();
alert(a);
})
</script>
It showing me 1,2......
But I want to change this default value and want to replace divisions name as a value.Like as
<option value="London">London</option>
<option value="Dhaka">Dhaka</option>
Solution
Try this for find method with list
$madDivisions = $this->MadStore->MadDivisions->find( 'list',
array(
'fields' => array(
'city_name',
'city_name'
)
)
);
city_name is the column name from database table which contains values for London, Dhaka.
Answered By - Pankaj Badukale Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.