how to add the values given in textbox of a form and to store the added value in the database field?
center[/center]
how to pass the values given to the textbox of the _form.php to the actionCreate() function in the controller directory?
Ex:
I have a database called result and the fields are "rollno,lang1,lang2,maths,science,sscience,total,result".
the _form.php coding
<?php
/* @var $this ResultController */
/* @var $model Result */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'result-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'rollno'); ?>
<?php echo $form->textField($model,'rollno',array('size'=>10,'maxlength'=>10)); ?>
<?php echo $form->error($model,'rollno'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'lang1'); ?>
<?php echo $form->textField($model,'lang1'); ?>
<?php echo $form->error($model,'lang1'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'lang2'); ?>
<?php echo $form->textField($model,'lang2'); ?>
<?php echo $form->error($model,'lang2'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'maths'); ?>
<?php echo $form->textField($model,'maths'); ?>
<?php echo $form->error($model,'maths'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'science'); ?>
<?php echo $form->textField($model,'science'); ?>
<?php echo $form->error($model,'science'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'sscience'); ?>
<?php echo $form->textField($model,'sscience'); ?>
<?php echo $form->error($model,'sscience'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'total'); ?>
<?php echo $form->textField($model,'total');?>
<?php echo $form->error($model,'total'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'result'); ?>
<?php echo $form->textField($model,'result',array('size'=>4,'maxlength'=>4)); ?>
<?php echo $form->error($model,'result'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
what i need to do is i need to add the values given to textfields of lang1,lang2,maths,science,sscience are added and to be store in the total field while hitting the create button?
I have tried the following
$model->total=$model->lang1+$model->lang2+$model->maths+$model->science+$model->sscience;
when i display the "$model->total" it will gives the added value.
but it wont store in the database.
how to do that?