fandi17
(Sastra Afandi)
1
need help, please…
I have a form and send the variabel from suratTugas1.php to coba1.php. but I can`t get the $_POST variable. the code are
suratTugas1.php
<?php echo $model->id; ?>
<?php echo CHtml::textField('Text'); ?>
<?php echo CHtml::button('submit',array('submit' => array('coba1', 'id'=>$model->id,'Text'=>$_POST['Text']))); ?>
</body>
</html>
in controller
function actionSuratTugas1($id){
$this->render('suratTugas1', array(
'model'=>$this->loadModel($id)));
}
function actionCoba1($id){
$this->renderPartial('coba1',array(
'model'=>$this->loadModel($id),'no'=>$_POST['Text']));
}
albertski
(Albertski84)
2
You can’t get the $_POST of the form element on that current page. You also will need a form widget.
This is more or less how the code should be:
public function actionSuratTugas1($id)
{
$this->render('suratTugas1', array(
'model'=>$this->loadModel($id)));
}
public function actionCoba1($id)
{
$text = '';
if(isset($_POST['Text'])) {
$text = $_POST['Text'];
}
$this->renderPartial('coba1',array(
'model'=>$this->loadModel($id),'no'=>$text));
}
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'suratTugas1',
));?>
<?php echo CHtml::textField('Text'); ?>
<?php echo CHtml::button('submit',array('submit' => array('create', 'id'=>$model->id))); ?>
<?php $this->endWidget(); ?>