Reputation: 31
I am trying to retrieve the data from a form created using a widget for CActiveForm. However, when I click on the submit button, no data is written to targeted Url. How do I obtain the submitted form data?
<p>Please list the ages of the members of your household:</p>
<div class="form offset3">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'survey',
'enableClientValidation' => true,
'enableAjaxValidation' => true,
'action'=>Yii::app()->createUrl('//survey_resp'),
'clientOptions' => array(
'validateOnSubmit' => true,
),
'htmlOptions' => array(
'class' => 'form-horizontal',
),
));
?>
<div class="row">
<?php echo $form->labelEx($model, 'age_1'); ?>
<?php echo $form->textField($model, 'age_1'); ?>
<?php echo $form->error($model, 'age_1'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'age_2'); ?>
<?php echo $form->textField($model, 'age_2'); ?>
<?php echo $form->error($model, 'age_2'); ?>
</div>
<div class="row rememberMe">
<?php echo $form->checkBox($model, 'resp_re'); ?>
<?php echo $form->Label($model, 'resp_re'); ?>
<?php echo $form->error($model, 'resp_re'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('submit'); ?>
</div>
<?php $this->endWidget(); ?>
Upvotes: 1
Views: 3446
Reputation: 782
Does "survey_resp" is your controller or your action ? If it's a action, then you should put the proper url for the form's action. example:
'action'=>Yii::app()->createUrl('/you_controller_name/your_action_name'),
ps: Remember, if you put "//" in a createUrl, it will generate an url to a basePath or module. See http://www.yiiframework.com/doc/api/1.1/CController#createUrl-detail and http://www.yiiframework.com/doc/api/1.1/CActiveForm#action-detail
Upvotes: 2