如何重新使用相同的控制器這裏是我的觀點的一部分:通過不同的形式輸入
echo $this->Form->create("Provider", array('action' => 'view_admit_lookup', ''));
echo $this->Form->input("last_name", array('label' => 'Doctor Last Name'));
echo $this->Form->submit('Search');
echo "<br><br>";
$alphabet = array(
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X",
"Y", "Z");
foreach($alphabet as $letter):
// create the row of buttons that are responsible for the search.
echo $this->Form->button($letter, array('action' => 'view_admit_lookup'));
endforeach;
現在,我希望能夠修改和再利用view_admit_lookup。
這裏是我的控制器方法:
function view_admit_lookup($letter) {
echo "<pre>The letter is: ".$letter."</pre>";
// here we begin searching for whatever we need.
if(!empty($this->data['Provider']['last_name'])) {
$this->set('provider',
$this->Provider->find('all',
array('conditions' =>
array('Provider.last_name LIKE' =>
$this->data['Provider']['last_name'].'%'),
'order' =>
array('Provider.last_name ASC',
'Provider.first_name ASC'),
)
)
);
}
// set the title and the default layout.
$this->set('title_for_layout', 'Admit Lookup');
$this->layout = 'default';
}
我如何「獲取」與輸入(按鈕或文本字段)相關聯的信,並基於該值的特定操作?
在一個正切線上,而不是'$ alphabet = array'('A','B','C',...'Z');',可以用'$ alphabet = range('A ','Z');'http://php.net/range – Farray