本文整理汇总了PHP中Model_Location::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Location::validate方法的具体用法?PHP Model_Location::validate怎么用?PHP Model_Location::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Location
的用法示例。
在下文中一共展示了Model_Location::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_edit
public function action_edit($id = null)
{
$location = Model_Location::find($id);
$val = Model_Location::validate('edit');
if ($val->run()) {
$location->name = Input::post('name');
$location->can_sell = Input::post('can_sell');
if ($location->save()) {
Session::set_flash('success', e('Updated location #' . $id));
Response::redirect('admin/locations');
} else {
Session::set_flash('error', e('Could not update location #' . $id));
}
} else {
if (Input::method() == 'POST') {
$location->name = $val->validated('name');
$location->can_sell = $val->validated('can_sell');
Session::set_flash('error', $val->error());
}
$this->template->set_global('location', $location, false);
}
$this->template->title = "Locations";
$this->template->content = View::forge('admin/locations/edit');
}
示例2: action_locations
public function action_locations($id = null)
{
$pass = Model_Pass::find($id);
if (Input::method() == 'POST') {
$val = Model_Location::validate('create');
if ($val->run()) {
$location = Model_Location::forge(array('latitude' => \Fuel\Core\Input::post('latitude'), 'longitude' => \Fuel\Core\Input::post('longitude'), 'altitude' => \Fuel\Core\Input::post('altitude', null), 'relevant_text' => \Fuel\Core\Input::post('relevant_text', null)));
$pass->locations[] = $location;
if ($location and $pass->save()) {
Session::set_flash('success', e('Added location #' . $location->id . '.'));
\Fuel\Core\Response::redirect('admin/pass/locations/' . $id);
return;
} else {
Session::set_flash('error', e('Could not save location.'));
}
} else {
Session::set_flash('error', $val->error());
}
}
$this->template->set_global('pass', $pass, false);
$this->template->title = "Pass Locations";
$this->template->content = View::forge('admin/pass/locations');
}