Returns an instance of the form to be used in this view.
483818
def get_form(self, form_class):
        """"""
        if not hasattr(self, '_form'):
            kwargs = self.get_form_kwargs()
            self._form = form_class(**kwargs)
        return self._form
474089
public function getFormService()
    {
        if (!array_key_exists('form', $this->services)) {
            $this->services['form'] = new Form($this->httpClient, $this->key);
        }

        return $this->services['form'];
    }
400504
def get_forms(self):
        
        forms = {}
        objects = self.get_objects()
        initial = self.get_initial()
        form_kwargs = self.get_form_kwargs()
        for key, form_class in six.iteritems(self.form_classes):
            forms[key] = form_class(instance=objects[key], initial=initial[key], **form_kwargs[key])
        return forms
1330339
def _get_form(self, config_name, only_required=False):
        """"""
        if getattr(self, config_name, None):
            return import_object_by_string(getattr(self, config_name))

        def use_field(field):
            if not only_required:
                return True
            return field.default == NOT_PROVIDED

        return modelform_factory(self.model, fields=[f.name for f in self.model.get_fields() if use_field(f)])
789360
def get_form(self, form_class=None):
        '''
        
        '''
        formobj = super(GenModify, self).get_form(form_class)

        # Set requested group to this form
        selfgroups = getattr(self, "form_groups", None)
        if selfgroups:
            if type(selfgroups) == list:
                formobj.__groups__ = lambda: selfgroups
            else:
                formobj.__groups__ = selfgroups
        else:
            selfgroups = getattr(self, "__groups__", None)
            if selfgroups:
                formobj.__groups__ = selfgroups

        # Return the new updated form
        return formobj
163614
def form(self, obj=None, form=None, name=None, template=None, var_name=None, validate_on_submit=True,\
        exit_on_failure=True, csrf_enabled=None):
        
        if not form or isinstance(form, str):
            if not name and isinstance(form, str):
                name = form
            if not name:
                name = request.endpoint.rsplit('.', 1)[1] if '.' in request.endpoint else request.endpoint
            if name not in self.forms:
                raise NoFormError("Cannot find form '%s'" % name)
            form = self.forms[name]
        if inspect.isclass(form):
            if isinstance(obj, dict):
                obj = DictObject(obj)
            if csrf_enabled is None:
                csrf_enabled = self.options["csrf_enabled"]
            form = form(obj=obj, meta={'csrf': csrf_enabled})

        current_context.data.form = form
        yield form

        if validate_on_submit and request.method == "POST":
            self.validate(form, exit_on_failure=exit_on_failure)
767038
def get_form_class(self, request, plugins, plugin):
        
        widget = self.get_editor_widget(
            request=request,
            plugins=plugins,
            plugin=plugin,
        )

        instance = plugin.get_plugin_instance()[0]

        if instance:
            context = RequestContext(request)
            context['request'] = request
            rendered_text = plugin_tags_to_admin_html(
                text=instance.body,
                context=context,
            )
        else:
            rendered_text = None

        # We avoid mutating the Form declared above by subclassing
        class TextPluginForm(self.form):
            body = CharField(widget=widget, required=False)

            def __init__(self, *args, **kwargs):
                initial = kwargs.pop('initial', {})

                if rendered_text:
                    initial['body'] = rendered_text
                super(TextPluginForm, self).__init__(*args, initial=initial, **kwargs)
        return TextPluginForm
410813
def get_filter(self):
        
        return self.filter_form_cls(self.request.GET,
                                    runtime_context=self.get_runtime_context(),
                                    use_filter_chaining=self.use_filter_chaining)
137794
def get_form(self, request, obj=None, **kwargs):
        
        widgets = kwargs.pop('widgets', {})
        labels = kwargs.pop('labels', {})
        glossary_fields = kwargs.pop('glossary_fields', self.glossary_fields)
        widgets.update(glossary=JSONMultiWidget(glossary_fields))
        labels.update(glossary='')  # remove label for glossary, since each subfields provides a label itself
        kwargs.update(widgets=widgets, labels=labels)
        form = super(CascadePluginBase, self).get_form(request, obj, **kwargs)
        # help_text can not be cleared using an empty string in modelform_factory
        form.base_fields['glossary'].help_text = ''
        if request.method == 'POST':
            is_shared = bool(request.POST.get('shared_glossary'))
            for field in glossary_fields:
                if not (is_shared and field.name in self.sharable_fields):
                    form.base_fields['glossary'].validators.append(field.run_validators)
        form.glossary_fields = glossary_fields
        return form
1204123
protected function formView()
    {
        // get form view
        $formView = $this->RequestContext->getControls()->getControl('action_form_view');

        if($formView == null || empty($formView)) {
            $formView = $this->RequestContext->getControls()->getControl('view');
        }

        return $formView;
    }
93701
public function getForm() {
		$form = new Form();
		
		$useBlacklist = (count($this->propertyBlacklist) > 0) ? true : false;
		$useWhitelist = (count($this->propertyWhitelist) > 0) ? true : false;
		
		$properties = EntityReader::getProperties($this->entityNamespace);
		foreach ($properties as $property) {
			$name = $property->getName();
			if (($useWhitelist && !in_array($name, $this->propertyWhitelist)) || ($useBlacklist && in_array($name, $this->propertyBlacklist))) {
				continue;
			}
			
			switch ($property->getType()) {
				case Property::PROPERTY_TYPE_COLUMN:
					if (!($property->getAnnotation() instanceof \Doctrine\ORM\Mapping\Id)) {
						$this->addColumnElementToForm($form, $property);
					}
					break;
				case Property::PROPERTY_TYPE_REF_ONE:
					$this->addSingleSelecterElementToForm($form, $property);
					break;
				case Property::PROPERTY_TYPE_REF_MANY:
					$this->addMultiSelecterElementToForm($form, $property);
					break;
				default:
					continue 2;
			}
		}
		
		$submit = new Submit('save');
		$submit->setValue('save');
		$form->add($submit);
		
		return $form;
	}
173865
def _construct_form(self, i, **kwargs):
        """"""
        form = super(MetadataFormset, self)._construct_form(i, **kwargs)
        # Monkey patch the form to always force a save.
        # It's unfortunate, but necessary because we always want an instance
        # Affect on performance shouldn't be too great, because ther is only
        # ever one metadata attached
        form.empty_permitted = False
        form.has_changed = lambda: True

        # Set a marker on this object to prevent automatic metadata creation
        # This is seen by the post_save handler, which then skips this
        # instance.
        if self.instance:
            self.instance.__seo_metadata_handled = True

        return form
569089
def construct_form(self, request):
        
        if not hasattr(self, 'form_class'):
            return None

        if request.method == 'POST':
            form = self.form_class(self.model, request.POST, request.FILES)
        else:
            form = self.form_class(self.model)
        return form
64241
public function createView()
    {
        if (!$this->formView) {
            $this->formView = new FormView();
        }

        $this->formView->setFormBlueprint($this->form);
        $this->formView->setFields($this->getProcessedFields());
        $this->formView->setSections($this->form->getSections());
        $this->formView->setMethod($this->getMethod());
        $this->formView->setName($this->getName());
        $this->formView->setEncoding($this->getEncoding());
        $this->formView->setAction($this->getAction());
        $this->formView->setSubmitted($this->isSubmitted());
        $this->formView->setValid($this->isValid());
        $this->formView->setErrors($this->getValidationErrors());
        $this->formView->setShouldShowSuccessMessage($this->shouldShowSuccessMessage());
        $this->formView->setSubmitButtonLabel($this->form->getSubmitButtonLabel());

        if (isset($this->restoreDataHandler)) {
            $this->restoreDataHandler->cancelRestore($this);
        }

        return $this->formView;
    }
524476
def use_form(form_class, request=None, **top_kwargs):
    

    def validated_form(request, **kwargs):
        # import ipdb; ipdb.set_trace()
        data = request.query_params.dict() if request.method in ['GET'] else request.data
        if isinstance(data, QueryDict):
            form = form_class(data={**data.dict(), **kwargs})
        elif isinstance(data, dict):
            form = form_class(data={**data, **kwargs})
        else:
            form = form_class(data=data, **kwargs)
        form.is_valid(raise_exception=True)
        return form

    if request:
        kwargs = {}
        if request.resolver_match:
            kwargs = {**request.resolver_match.kwargs}
        if top_kwargs:
            kwargs = {**kwargs, **top_kwargs}

        return validated_form(request, **kwargs).validated_data

    def wrap(func):
        def method_wrap(view, request, *args, **kwargs):
            form = validated_form(request, **kwargs)
            if hasattr(view, 'log'):
                form.log = view.log
            return func(view, form.validated_data, *args, **kwargs)

        def function_wrap(request, *args, **kwargs):
            form = validated_form(request, **kwargs)
            return func(form.validated_data, *args, **kwargs)

        def inner(*args, **kwargs):
            is_method = isinstance(args[0], APIView)
            return (method_wrap if is_method else function_wrap)(*args, **kwargs)

        return inner

    return wrap
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];
    }
885579
public function getCondForm() {
        $clz = static::class;
        if (isset(self::$forms[ $clz ])) {
            $form = self::$forms[ $clz ];

            return $form;
        }

        return null;
    }