Hi everyone I have some issue with my project,
I want to create a loan form which will be saved to database later.
But when I submit the data nothing happened. It seems the $_POST method didn’t send to the controller.
Here is the form
<?php
/* @var $this LoanController */
$this->breadcrumbs=array(
'Loan'=>array('/loan/loan'),
'Loan',
);
?>
<h1><?php echo "Loan"; ?></h1>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'loan-form',
'method'=>'post',
'enableClientValidation'=>true,
'enableAjaxValidation'=>false,
'clientOptions'=>array(
'validateOnSubmit'=>true,),
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<p class="note">Note : Borrowed time of book are 7 days.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->hiddenField($model,'borrower_id',array('value'=>Yii::app()->user->getId())); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'copy_id'); ?>
<?php echo $form->textField($model,'copy_id',array('value'=>$_GET['book_id'],'disabled'=>'true')); ?>
<?php echo $form->error($model,'copy_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'start_date'); ?>
<?php
$this->widget('application.extensions.timepicker.EJuiDateTimePicker',array(
'model'=>$model,
'attribute'=>'start_date',
'options'=>array(
'dateFormat'=>'yy-mm-dd',
'changeMonth' => true,
'changeYear' => false,
),
'htmlOptions'=>array('size'=>30,'class'=>'date', 'value'=>date("Y-m-d"))
));
?>
<?php echo $form->error($model,'start_date'); ?>
</div>
<div class="row">
<?php echo $form->hiddenField($model,'due_date',array('value'=>null)); ?>
</div>
<div class="row">
<?php echo $form->hiddenField($model,'return_date',array('value'=>null)); ?>
</div>
<div class="row">
<?php echo $form->hiddenField($model,'fines',array('value'=>0.00)); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Proceed' : 'Save'); ?>
</div>
<?php print_r($_POST); ?>
<?php $this->endWidget(); ?>
</div><!-- form -->
And this is the controller
<?php
class LoanController extends Controller
{
public function actionLoan()
{
$loan = new Loan;
// collect user input data
if (isset($_POST['LoanForm'])) {
//$loan->attributes = $_POST['loan'];
/* ....... */
die('Hello'); //just want to check if the controller get the $_POST method
$this->redirect(array('/site/index'));
}
// display the registration form
$this->render('makeLoan', array('model' => $loan));
}
?>
I check the $_POST method in the view page using
<?php print_r($_POST); ?>
And its work, it returns the value in the text field. Dont know why it didnt send to the controller.
Any kind of help will be appreciated.
Thank you.