Hi guys.
I am also having a problem dynamically creating a dropdown after selecting the date. Here is a little background of the application. I am trying to make a booking systems for a car wash. Only one car can be booked per hour and booking for the next day should stop after 1800. I have a model with the trading hours:
<?php
[color="#C0C0C0"]/**
*/[/color]
[color="#4169E1"]class[/color] Hours [color="#4169E1"]extends[/color] CActiveRecord
the only thing i added to this is a function to return the list of hours.
public static function hoursList(){
$model = Hours::model()->findAll();
$items = array();
foreach($model as $hours){
$items[$hours->times]=$hours->times;
}
return $items;
}
I am storing all my bookings in the bookings table and the model looks like this.
<?php
/**
-
The followings are the available columns in table ‘bookings’:
-
@property integer $id
-
@property string $time
-
@property string $date
-
@property integer $num_cars
-
@property string $treatment
-
@property integer $status
-
@property string $booking_ref
-
@property integer $user_id
*/
class Bookings extends CActiveRecord {
the view which is giving me a problem is like this:
<div class="form">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'bookings-form',
'enableAjaxValidation' => false,
));
?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<table>
<tr>
<td>
<?php echo $form->labelEx($model, 'date'); ?>
[color="#FF0000"] <?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model' => $model,
'attribute' => 'date',
// additional javascript options for the date picker plugin
'options' => array(
'showAnim' => 'fold',
'minDate' => Bookings::disableTomorrow(),
'onChange'=>CHtml::ajax(
array(
'type'=>'POST',
'url'=>CController::createUrl('bookings/dynamictime'),
'update'=>'#time',
)
)
),
'htmlOptions' => array(
'style' => 'height:20px;'
),
));
?>[/color]
<?php echo $form->error($model, 'date'); ?>
</td>
<td>
[color="#FF0000"] <?php echo $form->labelEx($model, 'time'); ?>
<?php echo $form->dropDownList($model, 'time', array()); ?>
<?php echo $form->error($model, 'time'); ?>[/color]
</td>
</tr>
<tr>
<td colspan="2">
<?php echo $form->labelEx($model, 'num_cars'); ?>
<?php echo $form->textField($model, 'num_cars'); ?>
<?php echo $form->error($model, 'num_cars'); ?>
</td>
</tr>
<tr>
<td colspan="2">
<?php echo $form->labelEx($model, 'treatment'); ?>
<?php echo $form->dropDownList($model, 'treatment', Bookings::treatmentList()); ?>
<?php echo $form->error($model, 'treatment'); ?>
</td>
</tr>
<tr>
<td colspan="2">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</td>
</tr>
</table>
<?php $this->endWidget(); ?>
</div><!-- form -->
The highlighted sections in particular…
I have also attached the files that I think are relevant to my problem.
PLZ HELP -> this is what it looks like now.
username: user
password: user
Book Now
1697
BookingsController.php