este es mi controller clients_controller:
Código PHP:
function riosini(){
$this->layout = 'main';
$module = 'Mrios';
$this->loadModel('Mrio');
$mrios3 = $this->Mrio->find('all',array('fields' => array('Mrio.periodo'),'group' => array('Mrio.periodo')));
$this->set('mrios3', $mrios3 );
$module = isset($this->params['named']['module'])?$this->params['named']['module']:null;
if (!$module) $this->redirect('index');
$periodo = $this->Mrio->find('all',array('fields' => array('Mrio.periodo'),'group' => array('Mrio.periodo')));
$pers = $this->Mrio->find('all',array('fields'=>'Mrio.periodo', 'group'=>array('Mrio.periodo')));
foreach ($pers as $peri) {
$per[$peri['Mrio']['periodo']]= $peri['Mrio']['periodo'];
}
$this->set('per',$per);
$this->set('periodo', $periodo);
$this->set('per', $per); //periodo en combo
$this->set('location', null); //region en combo
$this->set('nombre', null); //rio en combo
$this->set('module', $module);
}
Código HTML:
<?php echo $form->create('Propiedad',array('action'=>'clients')); ?> <table class="selectortable"> <tr> <td> Periodo <?php //pr($per); echo $form->input('periodo',array('label'=>false,'empty'=>array('0'=>'Selecciona el periodo'),'type'=>'select','onClick'=>'ajax_provincias(this.form)','options'=>$per)); ?> </td> </tr> <tr> <td> Region <div id='comboprovincias'> <?php echo $form->input('region',array('label'=>false,'empty'=>array('0'=>'Selecciona la region'),'type'=>'select','onClick'=>'ajax_provincias(this.form)','options'=>$location)); ?> </div> </td> </tr><tr> <td> Rios </td> </tr> </table> <?php echo $form->end(); ?>
Código HTML:
echo $form->input('periodo',array('label'=>false,'empty'=>array('0'=>'Selecciona el periodo'),'type'=>'select','options'=>$per,'onchange'=>$html->link($per,array('controller'=>'clients','action'=>'riosini','periodo:' . 'this.form', 'module:' . $module))));