The code below is added to the SiteController.php:
public function actionSearch()
{
$model=new SearchForm;
if(isset($_POST['SearchForm']))
{
$model->attributes=$_POST['SearchForm'];
if($model->validate())
$this->redirect(Yii::app()->user->returnUrl);
}
This is the model SearchForm.php:
<?php
/**
* SearchForm class.
* SearchForm is the data structure for keeping
* guest search form data. It is used by the 'search' action of 'SiteController'.
*/
class SearchForm extends CFormModel
{
public $city;
public $state;
public $dateStart;
public $dateEnd;
public $type;
public $beds;
public $range;
public $rememberMe;
/**
* Declares the validation rules.
* The rules state that city, dateStart, and dateEnd are required,
*
*/
public function rules()
{
return array(
array('city','length','max'=>30),
array('dateStart, dateEnd', 'required'),
);
}
/**
* Declares attribute labels.
*/
public function attributeLabels()
{
return array(
'city'=>'City',
'state'=>'State',
'dateStart'=>'Date Start',
'dateEnd'=>'Date End',
'type'=>'Category',
'beds'=>'Beds',
'range'=>'Price Range',
'rememberMe'=>'Remember Me Next Time',
);
}
}
This is view file search.php:
<?php $this->pageTitle=Yii::app()->name . ' - Search'; ?>
<h1> Search Form</h1>
<div class="yiiForm">
<?php echo CHtml::beginForm(); ?>
<?php echo CHtml::errorSummary($model); ?>
<div class="simple">
<?php echo CHtml::activeLabel($model,'city'); ?>
<?php echo CHtml::activeTextField($model,'city',array('size'=>30,'maxlength'=>30)); ?>
<?php echo CHtml::activeLabelEx($model,'state'); ?>
<?php
$statez = array('WA' => 'WA',
'NT' => 'NT',
'QLD'=> 'QLD',
'SA'=> 'SA',
'NSW'=> 'NSW',
'VIC'=> 'VIC',
'TAS'=> 'TAS');
echo CHtml::activeDropDownList($model,'state',$statez);
?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'dateStart'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
//'name'=>'dateStart',
'attribute'=>'dateStart',
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
'dateFormat'=>'yy-mm-dd',
//'showButtonPanel'=>'true',
// 'showAnim'=>'slideDown',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
), ));
?>
<?php echo CHtml::activeLabelEx($model,'dateEnd'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
// 'name'=>'dateEnd',
'attribute'=>'dateEnd',
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
'dateFormat'=>'yy-mm-dd',
//'showButtonPanel'=>'true',
// 'showAnim'=>'slideDown',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
), ));
?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'type'); ?>
<?php
$types = array('hotel'=>'hotel','motel'=>'motel','holapt'=>'holapt','resort'=>'resort',
'cvanCotCab'=>'cvanCotCab','bb'=>'bb');
echo CHtml::activeDropDownList($model,'type',$types);
?>
<?php echo CHtml::activeLabelEx($model,'beds'); ?>
<?php
$bedz = array('1'=>'1','2'=>'2','3'=>'3');
echo CHtml::activeDropDownList($model,'beds',$bedz);
?>
<?php echo CHtml::activeLabelEx($model,'range'); ?>
<?php
$rangez = array('0-30'=>'0-30','31-75'=>'31-75','76-150'=>'76-150','151 up'=>'151 up');
echo CHtml::activeDropDownList($model,'range',$rangez);
?>
</div>
<div class="action">
<?php echo CHtml::activeCheckBox($model,'rememberMe'); ?>
<?php echo CHtml::activeLabel($model,'rememberMe'); ?>
<br/>
<?php echo CHtml::submitButton('Find'); ?>
</div>
<?php echo CHtml::endForm(); ?>
</div><!-- yiiForm -->
Linking to the menu item produces only what’s in the H1 tags. The page title isn’t even rendered. Can someone give me an idea what’s stopping me from rendering this form? Thanks