Skip to content Skip to sidebar Skip to footer

Make Select Options Static To Dynamic

Select's Option Values are static & i want it dynamic Right now is static. as per below line Form->input('intaddressid', arr

Solution 1:

In ctp

<?phpecho$this->Form->input('intaddressid', array(
                    'options' => $courseCategoriesNames,
                    'empty' => '(choose one)',
                    'label' => false
                    ));
                ?>

UPDATED solution

In controller:

NEW

$arr1=array();
$arr2=array();

    $arr1= $this->Course->CourseCategory->find('list',
                                                        array('fields'=> array('Time.varaddress1'),
                                                              'order'=> array('Time.varaddress1')                                                                                                                                                                                                    )
                                            );


$arr2= $this->Course->CourseCategory->find('list',
                                                        array('fields'=> array('Time.varaddress1'),
                                                              'order'=> array('Time.varaddress2')                                                                                                                                                                                                    )
                                            );

    $finalArr=array_merge ($arr1,$arr2);
    $this->set('courseCategoriesNames',$finalArr);

FINAL ans //INSIDE model Your Time->

public$virtualFields = array('name_price' => 'concat(Time.varaddress1, "-", Time.varaddress2)');

////INSIDE model

$products=$this->Product->find('list',array('fields'=>  $this->Time->virtualFields['name_price'] )));
$this->set('products',compact($products));

Post a Comment for "Make Select Options Static To Dynamic"