Utility for turning liveforms into subforms, and compacting them as
        necessary.

        @param liveForm: a liveform.
        @type liveForm: L{LiveForm}

        @return: a sub form.
        @rtype: L{LiveForm}
964413
def _prepareSubForm(self, liveForm):
        
        liveForm = liveForm.asSubForm(self.name) # XXX Why did this work???
        # if we are compact, tell the liveform so it can tell its parameters
        # also
        if self._parameterIsCompact:
            liveForm.compact()
        return liveForm
1132125
def save(self, **kwargs):
        
        entry = super(FormForForm, self).save(commit=False)
        entry.form = self.form
        entry.entry_time = now()
        entry.save()
        entry_fields = entry.fields.values_list("field_id", flat=True)
        new_entry_fields = []
        for field in self.form_fields:
            field_key = "field_%s" % field.id
            value = self.cleaned_data[field_key]
            if value and self.fields[field_key].widget.needs_multipart_form:
                value = fs.save(join("forms", str(uuid4()), value.name), value)
            if isinstance(value, list):
                value = ", ".join([v.strip() for v in value])
            if field.id in entry_fields:
                field_entry = entry.fields.get(field_id=field.id)
                field_entry.value = value
                field_entry.save()
            else:
                new = {"entry": entry, "field_id": field.id, "value": value}
                new_entry_fields.append(FieldEntry(**new))
        if new_entry_fields:
            FieldEntry.objects.bulk_create(new_entry_fields)
        return entry
890687
def get_form(self):
        
        self.form = super(SmartFormMixin, self).get_form()

        fields = list(self.derive_fields())

        # apply our field filtering on our form class
        exclude = self.derive_exclude()
        exclude += self.derive_readonly()

        # remove any excluded fields
        for field in exclude:
            if field in self.form.fields:
                del self.form.fields[field]

        if fields is not None:
            # filter out our form fields
            remove = [name for name in self.form.fields.keys() if name not in fields]
            for name in remove:
                del self.form.fields[name]

        # stuff in our referer as the default location for where to return
        location = forms.CharField(widget=forms.widgets.HiddenInput(), required=False)

        if ('HTTP_REFERER' in self.request.META):
            location.initial = self.request.META['HTTP_REFERER']

        # add the location to our form fields
        self.form.fields['loc'] = location

        if fields:
            fields.append('loc')

        # provides a hook to programmatically customize fields before rendering
        for (name, field) in self.form.fields.items():
            field = self.customize_form_field(name, field)
            self.form.fields[name] = field

        return self.form
247508
protected function definition_sub() {
        $mform = $this->_form;

        $plugindefaults = get_config('workshopeval_best');
        $current = $this->_customdata['current'];

        $options = array();
        for ($i = 9; $i >= 1; $i = $i-2) {
            $options[$i] = get_string('comparisonlevel' . $i, 'workshopeval_best');
        }
        $mform->addElement('select', 'comparison', get_string('comparison', 'workshopeval_best'), $options);
        $mform->addHelpButton('comparison', 'comparison', 'workshopeval_best');
        $mform->setDefault('comparison', $plugindefaults->comparison);

        $this->set_data($current);
    }
1180838
def _makeDefaultLiveForm(self, (defaults, identifier)):
        
        parameters = [self._cloneDefaultedParameter(p, defaults[p.name])
                        for p in self.parameters]
        return self._makeALiveForm(parameters, identifier)
1322200
def smartformset_factory(form, formset=BaseFormSet, extra=1, can_order=False,
                         can_delete=False, min_num=None, max_num=None, validate_min=False, validate_max=False):
    """"""
    if max_num is None:
        max_num = DEFAULT_MAX_NUM
    # hard limit on forms instantiated, to prevent memory-exhaustion attacks
    # limit is simply max_num + DEFAULT_MAX_NUM (which is 2*DEFAULT_MAX_NUM
    # if max_num is None in the first place)
    absolute_max = max_num + DEFAULT_MAX_NUM
    if min_num is None:
        min_num = 0

    attrs = {'form': form, 'extra': extra,
             'can_order': can_order, 'can_delete': can_delete, 'min_num': min_num,
             'max_num': max_num, 'absolute_max': absolute_max, 'validate_min': validate_min,
             'validate_max': validate_max}
    return type(form.__name__ + str('FormSet'), (formset,), attrs)
1216061
def add_form(self, form, form_name, form_args):
        
        self.parentApp.addForm(form_name, form, **form_args)
        self.parentApp.change_form(form_name)
        return
193228
@RequestMapping(value = "configurations/create", method = RequestMethod.GET)
    public Form getConfigurationForm() {
        return StashConfiguration.Companion.form();
    }
64516
def get_form(self, request, obj=None, **kwargs):
        
        Form = type(str('ExtSharableForm'), (SharableCascadeForm, kwargs.pop('form', self.form)), {})
        Form.base_fields['shared_glossary'].limit_choices_to = dict(plugin_type=self.__class__.__name__)
        kwargs.update(form=Form)
        return super(SharableGlossaryMixin, self).get_form(request, obj, **kwargs)
571254
def formgroup_factory(form_classes,
                      formgroup=None,
                      state_validators=None,
                      ):
    

    base_class = formgroup or FormGroup
    if state_validators is not None:
        base_class = StateValidatorFormGroup

    if not issubclass(base_class, FormGroup):
        raise TypeError("Base formgroup class must subclass FormGroup.")

    return type(
        'FormGroup',
        (base_class,),
        dict(
            form_classes=form_classes,
            state_validators=state_validators,
        ),
    )
675266
def forms(self):
        
        if self._forms is None:
            self._forms = FormList(self)
        return self._forms
22537
public void modelCopyToForm(Model model, ModelForm form) throws Exception {
		try {
			PropertyUtils.copyProperties(form, model);
		} catch (Exception e) {
			String error = " Model:" + model.getClass().getName() + " copy To ModelForm:" + form.getClass().getName() + " error:" + e;
			Debug.logError(error, module);
			throw new Exception(error);
		}
	}
853601
public FormAction setValuesInForm(Form form) {
		FormAction formAction = new FormAction();
		form.setFormAction(formAction);
		this.forms.add(form);
		return formAction;
	}
183007
def forms(self):
        
        forms = MultiDict()
        for name, item in self.POST.iterallitems():
            if not hasattr(item, 'filename'):
                forms[name] = item
        return forms
588396
def get_form_kwargs(self):
        
        kwargs = super(SmartFormMixin, self).get_form_kwargs()
        kwargs['initial'] = self.derive_initial()
        return kwargs
202158
def get_form_instance(self, request, data=None, instance=None):
        
        defaults = {}
        if self.form:
            defaults['form'] = self.form
        if self.fields:
            defaults['fields'] = self.fields
        return modelform_factory(self.model, **defaults)(data=data, instance=instance)
736630
def get_form(self, form, name):
        
        kwargs = self.get_kwargs(form, name)
        form_class = self.get_form_class(form, name)
        composite_form = form_class(
            data=form.data if form.is_bound else None,
            files=form.files if form.is_bound else None,
            **kwargs)
        return composite_form