本文整理匯總了PHP中app::form方法的典型用法代碼示例。如果您正苦於以下問題:PHP app::form方法的具體用法?PHP app::form怎麽用?PHP app::form使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app
的用法示例。
在下文中一共展示了app::form方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: add
public function add($id = '/')
{
$page = $this->page($id);
$blueprint = blueprint::find($page);
$templates = $blueprint->pages()->template();
$options = array();
$back = array('subpages' => purl('subpages/index/' . $page->id()), 'page' => purl($page, 'show'));
$form = app::form('pages.add');
$form->save = l('add');
$form->back = a::get($back, get('to'));
foreach ($templates as $template) {
$options[$template->name()] = $template->title();
}
$select = form::field('select', array('name' => 'template', 'label' => l('pages.add.template.label'), 'options' => $options, 'required' => true));
if ($templates->count() == 1) {
$select->readonly = true;
$select->value = $templates->first()->name();
}
$form->fields()->append('template', $select);
if (api::maxPages($page, $blueprint->pages()->max())) {
$form->fields = array('info' => form::field('info', array('label' => 'pages.add.error.max.headline', 'text' => 'pages.add.error.max.text')));
$form->save = false;
$form->centered = true;
}
return view('pages/add', array('page' => $page, 'form' => $form));
}
示例2: index
public function index()
{
if (app::$site->users()->count() > 0) {
go('panel/login');
}
if ($problems = installation::check()) {
$content = view('installation/check', array('problems' => $problems));
} else {
$form = app::form('installation', array('language' => c::get('panel.language', 'en')));
$form->cancel = false;
$form->save = l::get('installation.signup.button');
$form->centered = true;
foreach (app::languages() as $lang) {
$form->fields()->get('language')->options[$lang->code()] = $lang->title();
}
$form->on('submit', function ($form) {
try {
app::$site->users()->create($form->serialize());
go('panel/login/welcome');
} catch (Exception $e) {
$form->alert($e->getMessage());
}
});
$content = view('installation/signup', array('form' => $form));
}
return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content));
}
示例3: login
public function login($welcome = null)
{
if ($user = app::$site->user()) {
go('panel');
}
$form = app::form('login');
$form->cancel = false;
$form->save = l('login.button');
$form->centered = true;
return layout('login', array('meta' => new Snippet('meta'), 'welcome' => $welcome ? l('login.welcome') : '', 'form' => $form));
}
示例4: form
protected function form($user = null)
{
$mode = $user ? 'edit' : 'add';
return app::form('user.' . $mode);
}