I have a form with some textfield with different ID and Name, here is the code:
<div class="form_default">
<fieldset>
<legend>Fields with <span class="required">*</span> are required.</legend>
<p>
<input type="radio" id="ps" name="status"> Ya, Saya telah berlangganan Premium Support<br/>
</p>
<p class="pss" style="display:none">
<?php echo CLabel::l($model, 'PSNO'); ?>
<?php echo $form->textField($model, 'PSNO'); ?>
<?php echo CLabel::e($model, 'PSNO'); ?>
</p>
<br/>
<p>
<input type="radio" id="nops" name="status"> Tidak, Saya belum berlangganan Premium Support<br/>
</p>
<p class="nopss" style="display:none">
<?php echo CLabel::l($model, 'BPCP'); ?>
<?php echo CHtml::textField('BP[BPCP]','', array('id'=>'BP_BPCP')); ?>
<?php echo CLabel::e($model, 'BPCP'); ?>
</p>
<p class="nopss" style="display:none">
<?php echo CLabel::l($model, 'BPMOBILE'); ?>
<?php echo CHtml::textField('BP[BPMOBILE]','', array('id'=>'BP_BPMOBILE')); ?>
<?php echo CLabel::e($model, 'BPMOBILE'); ?>
</p>
<p class="nopss" style="display:none">
<?php echo CLabel::l($model, 'BPEMAIL'); ?>
<?php echo CHtml::textField('BP[BPEMAIL]','', array('id'=>'BP_BPEMAIL')); ?>
<?php echo CLabel::e($model, 'BPEMAIL'); ?>
</p>
<p>
<?php echo CButton::b('Submit'); ?>
</p>
</fieldset>
</div><!-- form -->
<?php $this->endWidget(); ?>
<?php endif; ?>
</div>
<?php
Yii::app()->clientScript->registerScript('JQuery', "
$('#ps').click(function(){
$('#BP_BPCP').val(''),
$('#BP_BPMOBILE').val(''),
$('#BP_BPEMAIL').val(''),
$('p.nopss').hide(),
$('p.pss').show();
});
$('#nops').click(function(){
$('#Reqtv_PSNO').val(''),
$('p.nopss').show(),
$('p.pss').hide();
});
");
?>
as you can see, there are 2 radioButtons in there. so, when the first radioButton (ps) clicked, the JQuery function will run. And the second radioButton (nops) run the other JQuery function. So, the users need to fill the textFields that appears when the radioButton clicked. and when it submitted, it will send to a new function in my ReqtvController :
public function actionRequestTV() {
$this->layout = '//layouts/column1';
$this->bodyclass = 'bodygrey_without_leftbg';
$model = new Reqtv;
if (isset($_POST['Reqtv'])) {
$model->attributes = $_POST['Reqtv'];
$model->cekPSNO();
if ($model->save())
$this->redirect(array('step2', 'id' => $model->REQTVID));
}
elseif (isset($_POST['BP'])) {
$BP = new Customer;
$BP->attributes = $_POST['BP'];
if ($BP->save())
$this->redirect(array('step2B', 'id' => $BP->BPID));
}
$this->render('reqtvform_step1', array(
'model' => $model,
));
}
public function actionStep2($id) {
$this->layout = '//layouts/column1';
$this->bodyclass = 'bodygrey_without_leftbg';
$model = Reqtv::model()->findByPk($id);
$this->render('reqtvform_step2', array(
'id' => $id,
'model' => $model,
));
}
public function actionStep2B($id) {
$this->layout = '//layouts/column1';
$this->bodyclass = 'bodygrey_without_leftbg';
$model = new Reqtv;
$this->render('reqtvform_step2B', array(
'id' => $id,
'model' => $model,
));
}
my problem is, those codes won’t save the value that already given by the form. the second problem, this codes won’t work at all :
elseif (isset($_POST['BP'])) {
$BP = new Customer;
$BP->attributes = $_POST['BP'];
if ($BP->save())
$this->redirect(array('step2B', 'id' => $BP->BPID));
}
so, even though the submitted value is from KB textFields, it won’t do the function for $_POST[‘KB’] but do the function for $_POST[‘Reqtv’] instead
anybody can help?
thanks in advance