Button trouble

Hello!

I got a little issue with a button i am using.


	if(!isset($_POST['select_box_name']) && !Yii::app()->user->isGuest){

	

echo CHtml::beginForm();echo CHtml::dropDownList('select_box_name',

'',

CHtml::listData(Connections::model()->findAll(), 'id', 'Sidenavn'));


echo CHtml::submitButton('Select'); 

echo CHtml::endForm();

}

	else if(isset($_POST['select_box_name'])){

		

$_SESSION['dbid'] = $_POST['select_box_name'];

 echo CHtml::beginForm();

 echo CHtml::dropDownList('select_box_name',

$_POST['select_box_name'],

CHtml::listData(Connections::model()->findAll(), 'id', 'Sidenavn'));


echo CHtml::submitButton('Select',array('submit' => array('site/test')));

echo CHtml::endForm();

		

}

When i click my button first time, nothing happens but when i click it the next time, it reacts as intended.

Anyone know why this is?

(i know the code is horrible formed, im just doing some prototyping so i dont really care about that atm)

And what is intended?

NOTE: You are right the code is not nice… and it’s OK if you don’t mind it… but for posting to the forum… would be better if you get it cleaned… so maybe you would get better support… .as many users will not even try to read your code if it’s unreadable…

From the code… I presume… that the first time you have this button


echo CHtml::submitButton('Select'); 

but the second time you have this one


echo CHtml::submitButton('Select',array('submit' => array('site/test')));

And right you are, stupid little slip up. . .

And about the code part, ill keep that in mind for next time, Thanks!

:D

And now you see one more reason to clean the code… if you would have done so… you would get this "slip up"…