Yii Framework Forum: new select - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

new select Rate Topic: -----

#1 User is offline   ilovephp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 128
  • Joined: 04-February 11
  • Location:treviso

Posted 06 April 2011 - 02:19 AM

ciao ragazzi,

sto uscendo pazzo per un problema di select concatenate.

chi di voi a mai provato l'esempio ed è riuscito a farlo funzionare.

mi date una mano

grazie
la non conoscenza è una brutta bestia
0

#2 User is offline   sensorario 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,987
  • Joined: 07-September 10
  • Location:Cesena (Italy)

Posted 06 April 2011 - 02:27 AM

Mostraci il tuo codice.
0

#3 User is offline   nickcv 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 154
  • Joined: 23-November 10

Posted 06 April 2011 - 02:53 AM

nessun problema a dare una mano, ma come dice sensorario devi mostrarci il codice :P

le sfere di cristallo sono tutte dal ferramenta per la revisione
sometimes it's just like teaching pigs how to fly

Posted Image
Posted Image looking for some invite keys? welcome on B4K!
0

#4 User is offline   ilovephp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 128
  • Joined: 04-February 11
  • Location:treviso

Posted 06 April 2011 - 04:27 AM

ok grazie.

il mio controller è:
public function actionDynamiccities()	
	{
#		$_POST['country_id']=2;

		   	$data=Cities::model()->findAll('id_cities=:id_cities', 
           	array(':id_cities'=>(int) $_POST['country_id']));
 
		    $data=CHtml::listData($data,'id_cities','city');
    		foreach($data as $value=>$name)
		    {
		        echo CHtml::tag('option',
		                   array('value'=>$value),CHtml::encode($name),true);

			}

  	  }


la mia view è:
<?php
echo CHtml::dropDownList('country_id','', array(1=>'USA',2=>'France',3=>'Japan'),
array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>"CController::createUrl('responsabili/dynamiccities')", //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#city_id', //selector to update
//'data'=>'js:javascript statement' 
//leave out the data key to pass all form values through
'data'=>array('country_id'=>'js:this.selectedIndex'),
))); 
 
//empty since it will be filled by the other dropdown
echo CHtml::dropDownList('city_id','', array());
?>

il model l'ho creato con gii

e la struttura è il allegato 

Attached File(s)


la non conoscenza è una brutta bestia
0

#5 User is offline   sensorario 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,987
  • Joined: 07-September 10
  • Location:Cesena (Italy)

Posted 06 April 2011 - 09:21 AM

Emh... che errore ti da? Così a naso ho il sospetto che questo codice:
echo CHtml::dropDownList('city_id','', array());
non sia completo. O meglio, manca il secondo parametro. Potresti mandarci anche uno screenshot dell'errore?
0

#6 User is offline   ilovephp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 128
  • Joined: 04-February 11
  • Location:treviso

Posted 07 April 2011 - 03:26 AM

:lol: ;D :P ;D

il mio contributo per la comunity

finalmente dopo due/tre giorni sono riuscito a far funzionare l'esempio di Creating a dependent dropdown

il mio view è:
echo CHtml::dropDownList('country_id','', array(1=>'USA',2=>'France',3=>'Japan'),
array(
'ajax' => array(
'type'=>'POST', //request type
#'url'=>"index.php?r=responsabili/dynamiccities",
'url'=>CController::createUrl('responsabili/dynamiccities'),
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#city_id', //selector to update
//'data'=>'js:javascript statement' 
//leave out the data key to pass all form values through
'data'=>array('country_id'=>'js:this.selectedIndex'),
))); 
echo CHtml::dropDownList('city_id','', array());


il mio controller è:
public function actionDynamiccities()	
	{
			$data=Cities::model()->findAll('id_cities=:id_cities', 
           	array(':id_cities'=>((int) $_POST['country_id'])));
		    $data=CHtml::listData($data,'id','city');
    		foreach($data as $value=>$name)
		    {
			 echo CHtml::tag('option',array(
			 								'value'=>$value),
			 								CHtml::encode($name),true);
			}
  	  }

la non conoscenza è una brutta bestia
1

#7 User is offline   markux 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 106
  • Joined: 26-November 10
  • Location:Grosseto

Posted 07 April 2011 - 07:43 AM

ma la select è dentro un form?

http://www.yiiframew...dropdown/#c2156
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users