<?php return function ($user) { $form = new Kirby\Panel\Form(array('username' => array('label' => 'users.delete.headline', 'type' => 'text', 'readonly' => true, 'icon' => false, 'default' => $user->username(), 'help' => $user->email()))); $form->style('delete'); $form->cancel($user, 'edit'); return $form; };
<?php return function ($page, $textarea) { $form = new Kirby\Panel\Form(array('address' => array('label' => 'editor.email.address.label', 'type' => 'email', 'placeholder' => 'editor.email.address.placeholder', 'autofocus' => 'true', 'required' => 'true'), 'text' => array('label' => 'editor.email.text.label', 'type' => 'text', 'help' => 'editor.email.text.help', 'icon' => 'font'))); $form->data('textarea', 'form-field-' . $textarea); $form->style('editor'); $form->cancel($page); return $form; };
<?php return function ($page, $textarea) { $form = new Kirby\Panel\Form(array('url' => array('label' => 'editor.link.url.label', 'type' => 'text', 'placeholder' => 'http://', 'autofocus' => 'true', 'required' => 'true'), 'text' => array('label' => 'editor.link.text.label', 'type' => 'text', 'help' => 'editor.link.text.help'))); $form->data('textarea', 'form-field-' . $textarea); $form->style('editor'); $form->cancel($page, 'show'); return $form; };
<?php return function ($page) { $options = array(); foreach ($page->blueprint()->pages()->template() as $template) { $options[$template->name()] = $template->title(); } $form = new Kirby\Panel\Form(array('title' => array('label' => 'pages.add.title.label', 'type' => 'title', 'placeholder' => 'pages.add.title.placeholder', 'autocomplete' => false, 'autofocus' => true, 'required' => true), 'uid' => array('label' => 'pages.add.url.label', 'type' => 'text', 'icon' => 'chain', 'autocomplete' => false, 'required' => true), 'template' => array('label' => 'pages.add.template.label', 'type' => 'select', 'options' => $options, 'default' => key($options), 'required' => true, 'readonly' => count($options) == 1 ? true : false, 'icon' => count($options) == 1 ? $page->blueprint()->pages()->template()->first()->icon() : 'chevron-down'))); $form->cancel($page->isSite() ? '/' : $page); $form->buttons->submit->val(l('add')); return $form; };
<?php return function ($model) { $form = new Kirby\Panel\Form(array('entry' => array('label' => 'fields.structure.delete.label', 'type' => 'info'))); $form->style('delete'); $form->cancel($model); return $form; };
$roles = array(); // make sure the password is never shown in the form unset($content['password']); // add all languages foreach (panel()->translations() as $code => $translation) { $translations[$code] = $translation->title(); } // add all roles foreach (site()->roles() as $role) { $roles[$role->id()] = $role->name(); } // the default set of fields $fields = array('username' => array('label' => 'users.form.username.label', 'type' => 'text', 'icon' => 'user', 'autofocus' => $mode != 'edit', 'required' => true, 'help' => $mode == 'edit' ? 'users.form.username.readonly' : 'users.form.username.help', 'readonly' => $mode == 'edit'), 'firstName' => array('label' => 'users.form.firstname.label', 'autofocus' => $mode == 'edit', 'type' => 'text', 'width' => '1/2'), 'lastName' => array('label' => 'users.form.lastname.label', 'type' => 'text', 'width' => '1/2'), 'email' => array('label' => 'users.form.email.label', 'type' => 'email', 'required' => true, 'autocomplete' => false), 'password' => array('label' => $mode == 'edit' ? 'users.form.password.new.label' : 'users.form.password.label', 'required' => $mode == 'add', 'type' => 'password', 'width' => '1/2', 'suggestion' => true), 'passwordConfirmation' => array('label' => $mode == 'edit' ? 'users.form.password.new.confirm.label' : 'users.form.password.confirm.label', 'required' => $mode == 'add', 'type' => 'password', 'width' => '1/2'), 'language' => array('label' => 'users.form.language.label', 'type' => 'select', 'required' => true, 'width' => '1/2', 'default' => kirby()->option('panel.language', 'en'), 'options' => $translations), 'role' => array('label' => 'users.form.role.label', 'type' => 'select', 'required' => true, 'width' => '1/2', 'default' => site()->roles()->findDefault()->id(), 'options' => $roles, 'readonly' => !panel()->user()->isAdmin() or $user and $user->isLastAdmin())); if ($user) { // add all custom fields foreach ($user->blueprint()->fields()->toArray() as $name => $field) { if (array_key_exists($name, $fields)) { continue; } $fields[$name] = $field; } } // setup the form with all fields $form = new Kirby\Panel\Form($fields, $content); // setup the url for the cancel button $form->cancel('users'); if ($mode == 'add') { $form->buttons->submit->value = l('add'); } return $form; };
<?php return function ($file) { $form = new Kirby\Panel\Form(array('file' => array('label' => 'files.delete.headline', 'type' => 'text', 'readonly' => true, 'icon' => false, 'default' => $file->filename()))); $form->style('delete'); $form->cancel($file); return $form; };