<?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) { $parent = $page->parent(); $blueprint = $parent->blueprint(); $siblings = $parent->children()->visible(); // sorting needed if ($blueprint->pages()->num()->mode() == 'default' and $siblings->count() > 0) { $options = array('' => l('pages.toggle.invisible'), '-' => '-'); $n = 1; foreach ($siblings as $sibling) { $options[$n] = $n; $n++; } if ($page->isInvisible()) { $options[$n] = $n; } $form = new Kirby\Panel\Form(array('position' => array('label' => l('pages.toggle.position'), 'type' => 'select', 'required' => true, 'default' => $page->num(), 'options' => $options))); } else { $form = new Kirby\Panel\Form(array('confirmation' => array('type' => 'info', 'text' => $page->isVisible() ? l('pages.toggle.hide') : l('pages.toggle.publish')))); } $form->buttons->submit->value = l('change'); $form->buttons->submit->autofocus = true; $form->cancel($page); return $form; };
<?php return function ($page) { // create the form $form = new Kirby\Panel\Form($page->getFormFields(), $page->getFormData()); // add the blueprint name as css class $form->addClass('form-blueprint-' . $page->blueprint()->name()); // center the submit button $form->centered = true; // set the keep api $form->data('keep', $page->url('keep')); // set the autofocus on the title field $form->fields->title->autofocus = true; // add the changes alert if ($page->changes()->differ()) { // display unsaved changes $alert = new Brick('div'); $alert->addClass('text'); $alert->append('<span>' . l('pages.show.changes.text') . '</span>'); $form->buttons->prepend('changes', $alert); $form->buttons->cancel->attr('href', $page->url('discard')); $form->buttons->cancel->html(l('pages.show.changes.button')); // add wide buttons $form->buttons->cancel->addClass('btn-wide'); $form->buttons->submit->addClass('btn-wide'); } else { // remove the cancel button $form->buttons->cancel = ''; } // check for untranslatable fields if (panel()->site()->language() != panel()->site()->defaultLanguage()) {
<?php return function () { $translations = array(); foreach (panel()->translations() as $translation) { $translations[$translation->code()] = $translation->title(); } $form = new Kirby\Panel\Form(array('username' => array('label' => 'installation.signup.username.label', 'type' => 'text', 'icon' => 'user', 'placeholder' => 'installation.signup.username.placeholder', 'required' => true, 'autocomplete' => false, 'autofocus' => true), 'email' => array('label' => 'installation.signup.email.label', 'placeholder' => 'installation.signup.email.placeholder', 'type' => 'email', 'required' => true, 'autocomplete' => false), 'password' => array('label' => 'installation.signup.password.label', 'type' => 'password', 'required' => true, 'autocomplete' => false, 'suggestion' => true), 'language' => array('label' => 'installation.signup.language.label', 'type' => 'select', 'required' => true, 'autocomplete' => false, 'default' => kirby()->option('panel.language', 'en'), 'options' => $translations))); $form->attr('autocomplete', 'off'); $form->data('autosubmit', 'native'); $form->style('centered'); $form->buttons->submit->value = l('installation.signup.button'); return $form; };
<?php return function ($problems) { $form = new Kirby\Panel\Form(array('info' => array('type' => 'info'))); if (count($problems) > 1) { $info = new Brick('ol'); foreach ($problems as $problem) { $info->append('<li>' . $problem . '</li>'); } } else { $info = new Brick('p'); foreach ($problems as $problem) { $info->append($problem); } } // add the list of problems to the info field $form->fields->info->text = (string) $info; // setup the retry button $form->buttons->submit->value = l('installation.check.retry'); $form->buttons->submit->autofocus = true; $form->style('centered'); $form->alert(l('installation.check.text')); return $form; };
<?php return function ($avatar) { $form = new Kirby\Panel\Form(array('image' => array('type' => 'info'))); $form->fields->image->text = '(image: ' . $avatar->url() . ' class: avatar avatar-full avatar-centered)'; $form->centered = true; $form->style('delete'); 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 ($page) { $form = new Kirby\Panel\Form(array('page' => array('label' => 'pages.delete.headline', 'type' => 'text', 'readonly' => true, 'icon' => false, 'default' => $page->title(), 'help' => $page->id()))); $form->style('delete'); $form->cancel($page); 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 ($model, $structure) { $form = new Kirby\Panel\Form($structure->fields(), array(), $structure->field()); $form->cancel($model); $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; };