Form
@return Form
@throws \Propel\Runtime\Exception\PropelException
966808
protected function createComponentRedirectForm() : Form
    {
        $pages = [];
        $tree = $this->pageRepository->findAllByLevelNameByLangAsTree($this->activeLang);
        $collection = $this->pageRepository->findAllByLevelNameByLang($tree);

        foreach ($collection as $page)
        {
            $pages[$page->getId()] = $page->getName();
        }


        $form = new Form;

        $form->addText('oldUrl')
            ->setRequired('Původní URL je povinná.');

        $form->addSelect('pageId', NULL, $pages)
            ->setRequired('Cílová stránka je povinná.');

        $form->addSubmit('save');


        $form->onValidate[] = function (Form $form) { $this->validate($form); };
        $form->onSuccess[] = function (Form $form) { $this->success($form); };


        if ($this->redirectId)
        {
            $redirect = $this->onPageRepository->findOneRedirectById($this->redirectId);

            $form->setDefaults([
                'oldUrl' => $redirect->getOldUrl(),
                'pageId' => $redirect->getPageId()
            ]);
        }

        if (!$this->presenter->user->isAllowed(OnPageAuthorizator::RES_REDIRECT_FORM))
        {
            $this->setDisabledForm($form);
        }

        return $form;
    }
293615
protected function createComponentForgottenPasswordForm(): Form
	{
		$form = $this->formFactory->create();
		$form->addProtection();

		$form->addText('usernameOrEmail', 'cms.user.usernameOrEmail')
			->setRequired();

		$form->addSubmit('send', 'form.send');

		$form->addLink('back', 'form.back', $this->link('in'));

		$form->onSuccess[] = [$this, 'forgottenPasswordFormSucceeded'];

		return $form;
	}
1281601
public function DeliveryForm()
    {
        $form = DeliveryDetailsForm::create($this, 'DeliveryForm');

        $data = Session::get("Checkout.DeliveryDetailsForm.data");
        if (is_array($data)) {
            $form->loadDataFrom($data);
        }

        $this->extend("updateDeliveryForm", $form);

        return $form;
    }
122088
public function forms()
    {
        if (null === $this->forms) {
            $header = $this->header();

            // Call event to allow filling the page header form dynamically (e.g. use case: Comments plugin)
            $grav = Grav::instance();
            $grav->fireEvent('onFormPageHeaderProcessed', new Event(['page' => $this, 'header' => $header]));

            $rules = $header->rules ?? null;
            if (!\is_array($rules)) {
                $rules = [];
            }

            $forms = [];

            // First grab page.header.form
            $form = $this->normalizeForm($header->form ?? null, null, $rules);
            if ($form) {
                $forms[$form['name']] = $form;
            }

            // Append page.header.forms (override singular form if it clashes)
            $headerForms = $header->forms ?? null;
            if (\is_array($headerForms)) {
                foreach ($headerForms as $name => $form) {
                    $form = $this->normalizeForm($form, $name, $rules);
                    if ($form) {
                        $forms[$form['name']] = $form;
                    }
                }
            }

            $this->forms = $forms;
        }

        return $this->forms;
    }
788631
public function form()
    {
        $menuModel = config('admin.database.menu_model');
        $permissionModel = config('admin.database.permissions_model');
        $roleModel = config('admin.database.roles_model');

        $form = new Form(new $menuModel());

        $form->display('id', 'ID');

        $form->select('parent_id', trans('admin.parent_id'))->options($menuModel::selectOptions());
        $form->text('title', trans('admin.title'))->rules('required');
        $form->icon('icon', trans('admin.icon'))->default('fa-bars')->rules('required')->help($this->iconHelp());
        $form->text('uri', trans('admin.uri'));
        $form->multipleSelect('roles', trans('admin.roles'))->options($roleModel::all()->pluck('name', 'id'));
        if ($form->model()->withPermission()) {
            $form->select('permission', trans('admin.permission'))->options($permissionModel::pluck('name', 'slug'));
        }

        $form->display('created_at', trans('admin.created_at'));
        $form->display('updated_at', trans('admin.updated_at'));

        return $form;
    }
1159431
protected function _prepareForm()
    {
        $form = $this->formFactory->create();
        $this->setForm($form);

        /** @var \Mirasvit\Blog\Model\Post $post */
        $post = $this->registry->registry('current_model');

        $fieldset = $form->addFieldset('edit_fieldset', [
            'class' => 'blog__post-fieldset'
        ]);

        if ($post->getId()) {
            $fieldset->addField('entity_id', 'hidden', [
                'name'  => 'post[entity_id]',
                'value' => $post->getId(),
            ]);
        }

        $fieldset->addField('name', 'text', [
            'label'    => __('Title'),
            'name'     => 'post[name]',
            'value'    => $post->getName(),
            'required' => true,
        ]);

        $editorConfig = $this->wysiwygConfig->getConfig(['tab_id' => $this->getTabId()]);

        $fieldset->addField('content', 'editor', [
            'name'    => 'post[content]',
            'value'   => $post->getContent(),
            'wysiwyg' => true,
            'style'   => 'height:35em',
            'config'  => $editorConfig,
        ]);

        $fieldset->addField('short_content', 'editor', [
            'label'   => __('Excerpt'),
            'name'    => 'post[short_content]',
            'value'   => $post->getShortContent(),
            'wysiwyg' => true,
            'style'   => 'height:5em',
            'config'  => $editorConfig
        ]);


        return parent::_prepareForm();
    }
481308
public function createForm() : FormInterface
    {
        foreach ($this->value as $key => $val) {
            if (in_array($val['type'], $this->validMethods)) {
                $method = $val['type'];
                unset($val['type']);
                (!method_exists($this, $method)) ?: $this->{$method}($key, $val);
            } else {
                $this->input($key, $val);
            }

            if (isset($val['type']) && in_array($val['type'], $this->validArray)) {
                $this->setValidationError($key, $val);
            } elseif (!isset($val['type']) && in_array($method, $this->validArray)) {
                $this->setValidationError($key, $val);
            }
        }

        return $this;
    }
253759
protected function _prepareForm()
    {
        $form = $this->formFactory->create();
        $this->setForm($form);

        /** @var \Mirasvit\Blog\Model\Post $post */
        $post = $this->registry->registry('current_model');

        $fieldset = $form->addFieldset('image_fieldset', [
            'class'  => 'blog__post-fieldset',
            'legend' => __('Featured Image'),
        ]);

        $fieldset->addField('featured_image', 'image', [
            'required' => false,
            'name'     => 'featured_image',
            'value'    => $post->getFeaturedImageUrl(),
        ]);

        $fieldset->addField('featured_alt', 'text', [
            'required' => false,
            'label'   => __('Alt'),
            'name'     => 'post[featured_alt]',
            'value'    => $post->getFeaturedAlt(),
        ]);

        $fieldset->addField('featured_show_on_home', 'checkbox', [
            'label'   => __('Is show on Blog Home page'),
            'name'    => 'post[featured_show_on_home]',
            'value'   => 1,
            'checked' => $post->getFeaturedShowOnHome(),
        ]);

        return parent::_prepareForm();
    }
1301056
protected function createComponentAddForm(): Form
	{
		$form = $this->formFactory->create();
		$form->addProtection();

		$form->addText('username', 'cms.user.username')
			->setRequired();
		$form->addText('firstName', 'cms.user.firstName');
		$form->addText('surname', 'cms.user.surname');
		$form->addText('email', 'cms.user.email')
			->setRequired()
			->addRule(Form::EMAIL);
		$form->addPhone('phone', 'cms.user.phone');
		$form->addSelectUntranslated('language', 'cms.user.language', $this->localeService->allowed, 'form.none');

		$form->addMultiSelectUntranslated('roles', 'cms.permissions.roles', $this->orm->aclRoles->fetchPairs($this->user->isAllowed('dockbar.settings.permissions.superadmin', 'view')))
			->setRequired();

		if ($this->configurator->sendNewUserPassword) {
			$form->addCheckbox('generatePassword', 'cms.user.generatePassword')
				->addCondition($form::EQUAL, false)
				->toggle('password')
				->toggle('passwordVerify');
		} else {
			$form->addHidden('generatePassword', false);
		}

		$form->addPassword('password', 'cms.user.newPassword')
			->setOption('id', 'password')
			->addConditionOn($form['generatePassword'], Form::EQUAL, false)
			->setRequired()
			->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength)
			->endCondition();
		$form->addPassword('passwordVerify', 'cms.user.passwordVerify')
			->setOption('id', 'passwordVerify')
			->addConditionOn($form['generatePassword'], Form::EQUAL, false)
			->setRequired()
			->addRule(Form::EQUAL, null, $form['password'])
			->endCondition();

		$form->addSubmit('save', 'form.save');
		$form->addLink('back', 'form.back', $this->getBacklink());

		$form->onSuccess[] = [$this, 'addFormSucceeded'];
		return $form;
	}
653191
public function form()
    {
        return Administrator::form(function (Form $form) {
            $form->display('id', 'ID');

            $form->text('username', trans('admin.username'))->rules('required');
            $form->text('name', trans('admin.name'))->rules('required');
            $form->image('avatar', trans('admin.avatar'));
            $form->password('password', trans('admin.password'))->rules('required|confirmed');
            $form->password('password_confirmation', trans('admin.password_confirmation'))->rules('required')
                ->default(function ($form) {
                    return $form->model()->password;
                });

            $form->ignore(['password_confirmation']);

            $form->multipleSelect('roles', trans('admin.roles'))->options(Role::all()->pluck('name', 'id'));
            $form->multipleSelect('permissions', trans('admin.permissions'))->options(Permission::all()->pluck('name', 'id'));

            $form->display('created_at', trans('admin.created_at'));
            $form->display('updated_at', trans('admin.updated_at'));

            $form->saving(function (Form $form) {
                if ($form->password && $form->model()->password != $form->password) {
                    $form->password = bcrypt($form->password);
                }
            });
        });
    }
356670
public function Form()
    {
        if ($this->currentRecord) {
            $fields = $this->currentRecord->getFrontEndFields();
            $required = $this->currentRecord->getRequiredFields();
        } else {
            $fields = singleton($this->recordType)->getFrontEndFields();
            $required = singleton($this->recordType)->getFrontEndFields();
        }

        $fields->push(new HiddenField('ID'));
        $form = new Form($this, __function__, $fields, new FieldList(new FormAction('doSave', 'Save')), $required);
        if ($this->currentRecord) {
            $form->loadDataFrom($this->currentRecord);
        }
        return $form;
    }
1197630
public function execute()
    {
        $form = $this->formFactory->createNamed('', $this->type, $this->object);
        $form->handleRequest($this->stack->getCurrentRequest());

        if ($form->isValid()) {
            $this->postUpdate($this->object);

            return $this->object;
        }

        return $form;
    }
654170
protected function buildForm()
    {
        $this->form = Yii::createObject(array_merge([
            'scenario' => $this->scenario,
            'parent_id' => $this->parent_id,
            'parentTariff' => $this->parentTariff,
            'tariff' => $this->tariff,
        ], $this->getFormOptions()));
    }
1238863
public function getForm(string $name = '', array $form = null)
    {
        if (!isset($this->_forms[$name])) {
            $this->_forms[$name] = $this->createFormObject($name, $form);
        }

        return $this->_forms[$name];
    }
432703
public function execute()
    {
        $form = $this->formFactory->createNamed('', $this->type);
        $form->handleRequest($this->stack->getCurrentRequest());

        if ($form->isValid()) {
            $object = $form->getData();
            $this->repository->add($object);

            $this->postCreate($object);

            return $object;
        }

        return $form;
    }
285863
public function form()
    {
        return Merchant::form(Role::class, function (Form $form) {
            $form->display('id', 'ID');

            $form->text('slug', trans('merchant.slug'))->rules('required');
            $form->text('name', trans('merchant.name'))->rules('required');
            $form->listbox('permissions', trans('merchant.permissions'))->options(Permission::all()->pluck('name', 'id'));

            $form->display('created_at', trans('merchant.created_at'));
            $form->display('updated_at', trans('merchant.updated_at'));
        });
    }
1316066
public function getForm() {

		$form = new Form();
		
		// build a select control
		$getSelectControl = function ($property, $field, $values) use ($form) {
			
			$control = $form->addSelect($property)->setListByAssociativeArray($values, $values);
			
			if (static::isNullable($field) or static::isEmptiable($field)) {
				$control->prependEmpty();
			}
			
			return $control;
			
		};

		$properties = $this->getAllProperties();

		// these db column types will go into a textarea
		$textAreaTypes = ['tinytext', 'text', 'mediumtext', 'longtext'];

		foreach ($properties as $propName => $value) {

			$field = static::getMappedField($propName);

			// primary key
			if ($this->isKeyProperty($propName)) {

				$control = $form->addInput($propName)->setType('hidden');

			} else {
				
				$column = static::getColumnType($field);
				
				switch ($this->getPropertyType($propName)) {

					// checkbox
					case 'bool':
						$control = $form->addInput($propName)->setType('bool');
						break;
					
					// date or datetime
					case 'DateTime':
						$type = 'date' == $column->type ? 'date' : 'datetime'; 
						$control = $form->addInput($propName)->setType($type);
						break;

					// number with two decimals
					case 'float':
						$control = $form->addInput($propName)->setType('number')->setStep('0.01');
						break;

					// integer
					case 'int':
						$control = $form->addInput($propName)->setType('number');
						break;

					// multiple select
					case 'csv':
						$control = $getSelectControl($propName, $field, $column->length);
						$control->setMultiple();
						break;
					
					// select, textarea or text
					default:
						if ('enum' == $column->type) {
							$control = $getSelectControl($propName, $field, $column->length);
						} else if ('set' == $column->type) {
							$control = $getSelectControl($propName, $field, $column->length);
							$control->setMultiple();
						} else if (in_array($column->type, $textAreaTypes)) {
							$control = $form->addTextarea($propName);
						} else {
							$control = $form->addInput($propName);
							if (isset($column->length[0])) {
								$control->setMaxLength($column->length[0]);
							}
						}
						break;

				}

			}
			
			// check if is required
			if (!static::isNullable($field) and !static::isEmptiable($field)) {
				$control->setRequired();
			}

			// set the object value
			$control->setValue($value);

		}

		return $form;
		
	}