Reputation: 108
I'm trying to create a text box and a button. when the button is pressed, the input in the text box is passed to the next view. so far, I've been only able to write this:
echo CHtml::textField('text');
echo CHtml::button('Submit',array('submit' => array('site/result')));
which is pretty much just a plain button and text field. any help on what should i add to my code? and also, how do i retrieve a passed data in the other view?
Upvotes: 1
Views: 264
Reputation: 7647
Modify your view code like this
<?php
$this->beginWidget("CActiveForm",array(
'id'=>'new_view_action',
'action'=>array('site/result')
));
echo CHtml::textField('text');
echo CHtml::button('Submit',array('submit' => array('site/result')));
$this->endWidget();
?>
In your Site Controller Result action
class SiteController extends CController {
....
public function actionResult(){
if(isset($_POST['text'])){
$text = $_POST['text'] ;
// Do logic based on text value
$this->render('secondView',array('attributes'=>$attributes));
}
}
}
Upvotes: 1