[size="2"]Yes,[/size]
You can check it using following code in controller,
if(isset($_POST))
{
print_r([size="2"]$_POST[/size][size="2"]);[/size]
}
Hi Kiran, thanks for your reply again. I want to dig it a bit deeper. I will truely appreciate if you can help me. I’m now working on other people’s code. They have a submit button which is coded as:
<?php $this->widget('bootstrap.widgets.TbButton', array(
'buttonType' => 'submit',
'id' => 'completed-task',
'label' => TaskModule::t('Success'),
'type' => 'success',
'size' => 'normal',
'htmlOptions' => array('class' => 'input-block-level', 'name' => 'TaskForm[completed]', 'value' => '1'),
)); ?>
I thought if I clicked this button, the form data will send back to its original controller. However, what I found is that it may not go in. I attached the relevant part of code in controller and view at below. Please help me.
View:
<div class="taskbar">
<div class="container-fluid clearfix">
<div class="row-fluid">
<div class="span10">
<div class="task-info">
<h2 class="task-title">
<?php echo $task->title ?>
</h2>
<?php echo $task->description; ?>
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id'=>'task-form')); ?>
<?php echo $form->label($task,'answer', array('style'=>'display: inline; margin-right: 30px')); ?>
<?php echo $form->textField($task,'answer_tester', array('name'=> 'TaskForm[answer]')) ?>
</div>
</div>
<div class="span2">
<?php $this->widget('bootstrap.widgets.TbButton', array(
'buttonType' => 'submit',
'id' => 'completed-task',
'label' => TaskModule::t('Success'),
'type' => 'success',
'size' => 'normal',
'htmlOptions' => array('class' => 'input-block-level', 'name' => 'TaskForm[completed]', 'value' => '1'),
)); ?>
<?php $this->widget('bootstrap.widgets.TbButton', array(
'buttonType' => 'submit',
'id' => 'abandon-task',
'label' => TaskModule::t('Abandon'),
'type' => 'danger',
'size' => 'normal',
'htmlOptions' => array('class' => 'input-block-level', 'name' => 'TaskForm[abandon]', 'value' => '1'),
)); ?>
</div>
<?php
echo CHtml::hiddenField('TaskForm[session_id]', '', array('id' => 'session-id-field'));
echo CHtml::hiddenField('TaskForm[status]', '', array('id' => 'status-field'));
$this->endWidget();
?>
</div>
</div>
Controller:
public function wizardProcessStep($event)
{
// Load log from database, if any.
if ($event->sender->read('welcome') != null) {
$welcomeData = $event->sender->read('welcome');
if (isset($welcomeData['log_id']))
$this->_testLog = TestLog::model()->findByPk($welcomeData['log_id']);
}
if (strpos($event->step, 'task') !== false) {
$idSplit = explode('_', $event->step);
$taskNo = $idSplit[1];
$task = Task::model()->findByPk($taskNo);
if (isset($_POST['TaskForm'])) {
$session = TaskSession::model()->findByPk(intval($_POST['TaskForm']['session_id']));
// Consolidate all page duration into session.
$session->duration = Yii::app()->db->createCommand("SELECT SUM( TIME_TO_SEC(p.end_time) - TIME_TO_SEC(p.start_time) ) as `duration` FROM {{task_pages}} p WHERE p.session_id = :session")->bindValue(':session', $session->getAttribute('id'), PDO::PARAM_INT)->queryScalar();
// Check if last visited page is one of the success URLs.
if ($_POST['TaskForm']['status'] == 'completed') {
if ($session->withinSuccessUrl() && $session->withinTimeLimit() && $session->withinClickLimit()) {
$session->status = TaskSession::STATUS_COMPLETED;
}
} else {
$session->status = TaskSession::STATUS_ABANDONED;
}
$session->save();
$event->sender->save(null);
$event->handled = true;
return;
}
// Custom layout for tasks.
$this->layout = '//layouts/task';
$this->render('task', array('task' => $task, 'test' => $this->_testModel, 'log' => $this->_testLog, 'saved'=> $saved));
} else if (method_exists($this, 'step' . ucfirst($event->step))) {
// Allow steps to be processed by the individual functions if it exists.
$methodName = 'step' . ucfirst($event->step);
$this->$methodName($event);
}
}