Я получаю сообщение об ошибке, что моя переменная не определена на мой взгляд. На самом деле это моя первая поисковая форма (не только для торта), и я уверен, что я ошибаюсь. вот мой код контроллера:
ОБНОВЛЕНИЕ Вот новый код, как для действия контроллера, так и для HTML-формы.
<?php
$options = array('house' => 'House', 'condo' => 'Condo', 'hotel'=>'Hotel');
$attributes = array('legend' => 'Property:<span style="font-style:italic">(Please select one)</span>');
echo $this->Form->radio('Unit.type', $options, $attributes);
?>
<?php echo $this->Form->end('Search'); ?>
, который дает мне этот вывод:
<form action="/lodgings/search" id="UnitIndexForm" method="get" accept-charset="utf-8">
<fieldset><legend>Property:<span style="font-style:italic">(Please select one)</span></legend>
<input type="hidden" name="type" id="UnitType_" value=""/><input type="radio" name="type" id="UnitTypeHouse" value="house" />
<label for="UnitTypeHouse">House</label>
<input type="radio" name="type" id="UnitTypeCondo" value="condo" />
<label for="UnitTypeCondo">Condo</label>
<input type="radio" name="type" id="UnitTypeHotel" value="hotel" />
<label for="UnitTypeHotel">Hotel</label>
</fieldset>
<div class="submit">
<input type="submit" value="Search"/>
</div>
</form>
Теперь моя логика контроллера:
function search() {
$result = array();
if (isset($this->params['url'] ))
{
$type = $this->params['url'];
$conditions = array("Unit.type = " => $type, 'Unit.active'=>1);
$result = $this->Unit->find('all', array('conditions'=> $conditions));
$this->log(print_r($result, true));
$this->set('type', $result);
}
}