kitune
(Shinkitune)
1
Hi!
I trying to use a dropodownlist to changue a user session variable "carpeta".
<?php
echo CHtml::dropDownList('cliente','',CHtml::listData(Clientes::model()->findAll(),'id_cliente','nombre'),
array(
'empty'=>'- Selecciona un cliente -',
'onchange'=>Yii::app()->user->setState('carpeta', OPTION-SELECTED),
));
?>
Is this possible?? thanks!
zaccaria
(Matteo Falsitta)
2
Is not possible, here you should write a js function.
You can use onChange for fire an ajax request, wich calls an action wich set your variable.
kitune
(Shinkitune)
3
Ok, I solved with an action call:
<?php
echo CHtml::dropDownList('cliente','',CHtml::listData(Clientes::model()->findAll(),'id_cliente','nombre'),
array(
'empty'=>'- Selecciona un cliente -',
'onchange'=>'js:$("#cargar-archivo").slideDown("slow")',
'ajax'=>array(
'type' => 'POST',
'url' => Yii::app()->createUrl('admin/archivos/cambiarcarpeta/'),
'data'=>"js:{clientId: $(this).val()}",
)
));
?>
and,
public function actionCambiarcarpeta()
{
$id_cliente=$_POST['clientId'];
Yii::app()->user->setState('carpeta',$id_cliente);
Yii::app()->end();
}
thanks zaccaria!
zaccaria
(Matteo Falsitta)
4
You are welcome, I am glad that it helped.
Bibi40k
(It)
5
Hi,
i have this scenario and i don’t know how to adapt this
vehicle type (car / motorcycle)
if i choose car, next dropdown should populate from "car make" table and after selection "car model"
the same for motorcycle
Could you please help me ?