Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Select's Option Values are static & i want it dynamic

Right now is static. as per below line

<?echo $this->Form->input('intaddressid', 
                            array(
                                'options' => 
                                    array('add1static,add1static' => 'add1static,add1static',
                                          'addres2static,add2stattic'=>'addres2static,add2stattic'),
                                'label'=>false,
                                'empty' => '(Select hotel and time)',
                                'class' => 'form-control border_none'
                            )
                        );
?>

My static field output https://www.dropbox.com/s/6133d4e9aorpo33/Selection_047.png?dl=0

And if i set for each then my dynamic https://www.dropbox.com/s/v3hfhfaubkfr62m/Selection_048.png?dl=0

But i want it only in 1 field all value so help on it

I used for each times as time and my table value generated but now i want this value in above my static code. value => add1,add2 = add1,add2

$times['Time']['varaddress1'] $times['Time']['varaddress2']

my updated code is ->

$arr1=array();

$arr2=array();

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

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

$finalArr=array_merge ($arr1,$arr2);

$this->set('time',$finalArr);

and in ctp i used

'options' => $time

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
176 views
Welcome To Ask or Share your Answers For Others

1 Answer

In ctp

               <?php
                    echo $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));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...