Returns a Form for page searching for use in templates.

Can be modified from a decorator by a 'updateSearchForm' method

@return Form
332878
public function getSearchForm()
    {
        // Create the fields
        $dateFrom = DateField::create(
            'Search__LastEditedFrom',
            _t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATEFROM', 'From')
        )->setLocale(Security::getCurrentUser()->Locale);
        $dateTo = DateField::create(
            'Search__LastEditedTo',
            _t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATETO', 'To')
        )->setLocale(Security::getCurrentUser()->Locale);
        $filters = CMSSiteTreeFilter::get_all_filters();
        // Remove 'All pages' as we set that to empty/default value
        unset($filters[CMSSiteTreeFilter_Search::class]);
        $pageFilter = DropdownField::create(
            'Search__FilterClass',
            _t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGES', 'Page status'),
            $filters
        );
        $pageFilter->setEmptyString(_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGESALLOPT', 'All pages'));
        $pageClasses = DropdownField::create(
            'Search__ClassName',
            _t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'),
            $this->getPageTypes()
        );
        $pageClasses->setEmptyString(_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGETYPEANYOPT', 'Any'));

        // Group the Datefields
        $dateGroup = FieldGroup::create(
            _t('SilverStripe\\CMS\\Search\\SearchForm.PAGEFILTERDATEHEADING', 'Last edited'),
            [$dateFrom, $dateTo]
        )->setName('Search__LastEdited')
        ->addExtraClass('fieldgroup--fill-width');

        // Create the Field list
        $fields = new FieldList(
            $pageFilter,
            $pageClasses,
            $dateGroup
        );

        // Create the form
        /** @skipUpgrade */
        $form = Form::create(
            $this,
            'SearchForm',
            $fields,
            new FieldList()
        );
        $form->addExtraClass('cms-search-form');
        $form->setFormMethod('GET');
        $form->setFormAction(CMSMain::singleton()->Link());
        $form->disableSecurityToken();
        $form->unsetValidator();

        // Load the form with previously sent search data
        $form->loadDataFrom($this->getRequest()->getVars());

        // Allow decorators to modify the form
        $this->extend('updateSearchForm', $form);

        return $form;
    }
1132897
public function updateSearchForm(Form $form) {
		$cms = $this->owner;
		$req = $cms->getRequest();

		$sites = Site::get()->sort(array(
			'IsDefault' => 'DESC',
			'Title'     => 'ASC'
		));

		$site = new DropdownField(
			'q[SiteID]',
			_t('Multisites.SITE', 'Site'),
			$sites->map(),
			isset($req['q']['SiteID']) ? $req['q']['SiteID'] : null
		);
		$site->setEmptyString(_t('Multisites.ALLSITES', 'All sites'));

		$form->Fields()->insertAfter($site, 'q[Term]');
	}
810382
protected function _getSelectForm()
    {
        $form = new \Gems_Form(array('name' => 'autosubmit', 'class' => 'form-inline', 'role' => 'form'));

        $form->setHtml('div');
        $div = $form->getHtml();
        $div->class = 'search';

        $span = $div->div(array('class' => 'panel panel-default'))->div(array('class' => 'inputgroup panel-body'));

        $element = $form->createElement('select', 'gpa_level', array(
            'multiOptions' => $this->patchLevels,
            'onchange' => 'this.form.submit();',
            'onkeyup' => 'this.form.submit();',
            ));

        $element->setValue($this->getPatchLevel());
        $span->input($element);

        $form->addElement($element);

        $submit = $form->createElement('submit', 'search', array(
            'label' => $this->_('Search'),
            'class' => 'button small',
            ));

        $span->input($submit);
        $form->addElement($submit);

        return $form;
    }
997044
def get_form(self, request, obj=None, **kwargs):
        """"""

        template = get_template_from_request(request, obj)

        #model = create_page_model(get_placeholders(template))

        form = make_form(self.model, get_placeholders(template))

        # bound the form
        language = get_language_from_request(request)
        form.base_fields['language'].initial = language
        if obj:
            initial_slug = obj.slug(language=language, fallback=False)
            initial_title = obj.title(language=language, fallback=False)
            form.base_fields['slug'].initial = initial_slug
            form.base_fields['title'].initial = initial_title

        template = get_template_from_request(request, obj)
        page_templates = settings.get_page_templates()
        template_choices = list(page_templates)
        # is default template is not in the list add it
        if not [tpl for tpl in template_choices if tpl[0] == settings.PAGE_DEFAULT_TEMPLATE]:
            template_choices.insert(0, (settings.PAGE_DEFAULT_TEMPLATE,
                    _('Default template')))
        form.base_fields['template'].choices = template_choices
        form.base_fields['template'].initial = force_text(template)

        for placeholder in get_placeholders(template):
            ctype = placeholder.ctype
            if obj:
                initial = placeholder.get_content(obj, language, lang_fallback=False)
            else:
                initial = None
            form.base_fields[ctype] = placeholder.get_field(obj,
                language, initial=initial)

        return form
1066097
public function updateSearchForm(Form $form)
    {
        if ($this->isVersioned()) {
            
            // Obtain Field List:
            
            $fields = $form->Fields();
            
            // Create Filter Field:
            
            $filter = DropdownField::create(
                'q[FilterClass]',
                $this->owner->getStatusFieldTitle(),
                $this->getFilterClassOptions(),
                $this->getFilterClass()
            )->setForm($form);
            
            // Add Filter Field to Form:
            
            if ($this->owner->StatusFieldBefore) {
                $fields->insertBefore(sprintf('q[%s]', $this->owner->StatusFieldBefore), $filter);
            } elseif ($this->owner->StatusFieldAfter) {
                $fields->insertAfter(sprintf('q[%s]', $this->owner->StatusFieldAfter), $filter);
            } else {
                $fields->push($filter);
            }
            
        }
    }
728461
public function getFormTemplate()
    {
        if (null === $this->formTemplate) {
            $template = rtrim($this->getTemplatePrefix(), '/') . '/' . $this->getFormSuffix();
            $this->setFormTemplate($template);
        }

        return $this->formTemplate;
    }
259434
protected function createComponentEditForm(): Form
	{
		$form = $this->formFactory->create();

		$form->addText('name', 'default.name')
			->setRequired();

		if ($this->editConst) {
			$form->addText('const', 'webManager.web.content.const')
				->setRequired();

			$form->addSelectUntranslated('locale', 'webManager.web.pages.locale')
				->setItems($this->localeService->allowed);
		}

		$form->addText('title', 'webManager.web.content.contentTitle')
			->addRule(Form::MAX_LENGTH, null, 150)
			->setRequired(false);

		$form->addTextArea('keywords', 'webManager.web.content.keywords');

		$form->addImageUpload('image', 'webManager.web.content.photo', 'webManager.web.content.photoDelete')
			->setNamespace('content')
			->setPreview('300x100');

		$form->addColor('background', 'webManager.web.content.background');

		$form->addTextArea('description', 'webManager.web.content.description');

		$form->addTextEditor('content', 'webManager.web.content.content');

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

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

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

		return $form;
	}
360500
public function CartForm()
    {   
        $form = Form::create(
            $this,
            "CartForm",
            FieldList::create(),
            FieldList::create(
                FormAction::create(
                    'doUpdate',
                    _t('ShoppingCart.UpdateCart', 'Update Cart')
                )->addExtraClass('btn btn-info')
            )
        )->setTemplate("SilverCommerce\ShoppingCart\Forms\Includes\ShoppingCartForm");
        
        $this->extend("updateCartForm", $form);
        
        return $form;
    }
103479
public function searchAction()
    {
        $form = $this->formSearch;

        if ($this->getRequest()
                 ->isPost()
        ) {
            $form->setData(
                $this->params()
                     ->fromPost()
            );

            if ($form->isValid()) {
                return $this->redirect()
                            ->toRoute(
                                'mp3-search',
                                [
                                    'name' => $this->params()
                                                   ->fromPost('name')
                                ]
                            );
            }
        }

        $service = $this->serviceSearch
            ->find(
                $this->params()
                     ->fromRoute('name')
            );

        return (new ViewModel())
            ->setTemplate('mp3/mp3/search')
            ->setVariables(
                [
                    'form'          => $form,
                    'paginator'     => $service['paginator'],
                    'totalLength'   => $service['totalLength'],
                    'totalFileSize' => $service['totalFileSize'],
                    'search'        => $service['search'],
                    'flash'         => $this->params()
                                            ->fromRoute('flash')
                ]
            );
    }
850038
def get_search_form(self):
        
        magic_dico_form = self.get_dict_for_forms()
        forms = []
        initial = list(self.request.GET.lists())

        for key, value in magic_dico_form.items():
            form = Form()
            model = value["model"]
            if not value["fields"]:
                continue
            for field in value["fields"]:
                formfield = get_formfield(model, field)
                formfield.widget.attrs.update({'class': self.css_class})
                form.fields.update({
                    field : formfield
                })

            initial_tmp = {}
            for k, vals in initial:
                tmp_list = k.split(model.__name__ + "-")
                if len(tmp_list) == 2:
                    list_val_tmp = vals[0] if len(vals) == 1 else [val for val in vals if val != '']
                    initial_tmp[tmp_list[-1]] = list_val_tmp

            form.initial = initial_tmp
            form.prefix = model.__name__
            forms.append(form)
        return sorted(forms, key=lambda form: form.prefix)
625757
def get_form(self, request, obj=None, **kwargs):
        """"""
        #form = super(PageAdmin, self).get_form(request, obj, **kwargs)
        template = get_template_from_request(request, obj)
        form = make_form(self.model, get_placeholders(template))

        language = get_language_from_request(request)
        form.base_fields['language'].initial = language
        if obj:
            initial_slug = obj.slug(language=language, fallback=False)
            initial_title = obj.title(language=language, fallback=False)
            form.base_fields['slug'].initial = initial_slug
            form.base_fields['title'].initial = initial_title
            form.base_fields['slug'].label = _('Slug')

        template = get_template_from_request(request, obj)
        page_templates = settings.get_page_templates()
        if len(page_templates) > 0:
            template_choices = list(page_templates)
            template_choices.insert(0, (settings.PAGE_DEFAULT_TEMPLATE,
                    _('Default template')))
            form.base_fields['template'].choices = template_choices
            form.base_fields['template'].initial = force_text(template)

        for placeholder in get_placeholders(template):
            name = placeholder.name
            if obj:
                initial = placeholder.get_content(obj, language, name)
            else:
                initial = None
            form.base_fields[name] = placeholder.get_field(obj,
                language, initial=initial)

        for placeholder in self.metadata_fields:
            name = placeholder['name']
            initial = None
            if obj:
                try:
                    initial = Content.objects.get(page=obj, language=language, type=name).body
                except Content.DoesNotExist:
                    pass
            form.base_fields[name] = placeholder['field']
            form.base_fields[name].initial = initial

        return form
580999
public function SearchForm()
    {
        $searchText =  _t('SilverStripe\\CMS\\Search\\SearchForm.SEARCH', 'Search');
        /** @var HTTPRequest $currentRequest */
        $currentRequest = $this->owner->getRequest();

        if ($currentRequest && $currentRequest->getVar('Search')) {
            $searchText = $currentRequest->getVar('Search');
        }

        $fields = FieldList::create(
            TextField::create('Search', false, $searchText)
        );
        $actions = FieldList::create(
            FormAction::create('results', _t('SilverStripe\\CMS\\Search\\SearchForm.GO', 'Go'))
        );
        return SearchForm::create($this->owner, 'SearchForm', $fields, $actions);
    }
271967
protected function _prepareForm()
    {
        $form = $this->formFactory->create();
        $this->setForm($form);

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

        $fieldset = $form->addFieldset('edit_fieldset', [
            'legend' => __('Search Engine Optimization')
        ]);

        $fieldset->addField('url_key', 'text', [
            'label' => __('URL Key'),
            'name'  => 'url_key',
            'value' => $category->getUrlKey(),
        ]);

        $fieldset->addField('meta_title', 'text', [
            'label' => __('Meta Title'),
            'name'  => 'meta_title',
            'value' => $category->getMetaTitle(),
        ]);

        $fieldset->addField('meta_description', 'textarea', [
            'label' => __('Meta Description'),
            'name'  => 'meta_description',
            'value' => $category->getMetaDescription(),
        ]);

        $fieldset->addField('meta_keywords', 'textarea', [
            'label' => __('Meta Keywords'),
            'name'  => 'meta_keywords',
            'value' => $category->getMetaKeywords(),
        ]);

        return parent::_prepareForm();
    }
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;
    }
1254628
def get_form(self, form_class=None):
        """"""
        form = super().get_form(form_class)

        if not getattr(form, 'helper', None):
            form.helper = FormHelper()
            form.helper.form_tag = False
        else:
            form.helper.form_tag = False
        return form
388400
def get_form(self, form_class=None):
        """"""
        form = super().get_form(form_class)
        if self._save:
            make_form_or_formset_fields_not_required(form)
        return form
280189
def get_form(self, form_class):
        """"""
        kwargs = self.kwargs
        kwargs.update(self.get_form_kwargs())
        kwargs.update({
            'request': self.request,
            'next_view': WidgetCreateView
        })
        return form_class(**kwargs)