Hi
I have this codes, Someone help me get the right controller code to save the model data
View Code:
<?php echo $form->hiddenField($model, 'floor', array('size' => 60, 'maxlength' => 120, 'value' => $_REQUEST['id'])); ?>
<?php
$floors = Floor::model()->findByAttributes(array('id' => $_REQUEST['id']));
for ($i = 0; $i < $floors->no_of_rooms; $i++) {
?>
<table border="1">
<tbody>
<tr>
<td><?php echo $form->labelEx($model, 'room_no'); ?></td>
<td>
<?php echo $form->textField($model, 'room_no', array('size' => 20, 'maxlength' => 120)); ?>
<?php echo $form->error($model, 'room_no'); ?>
</td>
</tr>
<tr>
<td><?php echo $form->labelEx($model, 'no_of_bed'); ?></td>
<td>
<?php echo $form->textField($model, 'no_of_bed', array('size' => 20, 'maxlength' => 120)); ?>
<?php echo $form->error($model, 'no_of_bed'); ?>
</td>
</tr>
</tbody>
</table>
<?php
}
?>
controller code:
public function actionCreate() {
$model = new Room;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Room'])) {
$model->attributes = $_POST['Room'];
if ($model->save()) {
$this->redirect(array('admin', 'id' => $model->id));
}
}
$this->render('create', array(
'model' => $model,
));
}