Builds a dynamic form that targets only the field in question, and saves the modification.
429925
def post(self, request, *args, **kwargs):
        
        self.object_list = None
        form = self.get_xeditable_form(self.get_xeditable_form_class())
        if form.is_valid():
            obj = self.get_update_object(form)
            if obj is None:
                data = json.dumps({
                    'status': 'error',
                    'message': "Object does not exist."
                })
                return HttpResponse(data, content_type="application/json", status=404)
            return self.update_object(form, obj)
        else:
            data = json.dumps({
                'status': 'error',
                'message': "Invalid request",
                'form_errors': form.errors,
            })
            return HttpResponse(data, content_type="application/json", status=400)
771963
public function setForm($form)
    {
        foreach ($this->fields as $field) {
            $field->setForm($form);
        }
        
        return parent::setForm($form);
    }
656676
def patch_clean_fields(model):
    
    old_clean_fields = model.clean_fields

    def new_clean_fields(self, exclude=None):
        if hasattr(self, '_mt_form_pending_clear'):
            # Some form translation fields has been marked as clearing value.
            # Check if corresponding translated field was also saved (not excluded):
            # - if yes, it seems like form for MT-unaware app. Ignore clearing (left value from
            #   translated field unchanged), as if field was omitted from form
            # - if no, then proceed as normally: clear the field
            for field_name, value in self._mt_form_pending_clear.items():
                field = self._meta.get_field(field_name)
                orig_field_name = field.translated_field.name
                if orig_field_name in exclude:
                    field.save_form_data(self, value, check=False)
            delattr(self, '_mt_form_pending_clear')
        old_clean_fields(self, exclude)
    model.clean_fields = new_clean_fields
1117062
def form_field(self):
        ""
        label = unicode(self)
        defaults = dict(required=False, label=label, widget=self.widget)
        defaults.update(self.extra)
        return self.field_class(**defaults)
91528
def change_and_save(self, update_only_changed_fields=False, **changed_fields):
        
        change_and_save(self, update_only_changed_fields=update_only_changed_fields, **changed_fields)
        return self
1293382
def edit_form(self, obj):
        """"""
        form = super(OAISetModelView, self).edit_form(obj)
        del form.spec
        return form
579667
protected function execUpdateForm()
    {
        // form translations
        $this->loadTranslations('form', sprintf('private/global/locales/%s/form.ini', LANGUAGE));
        // get record
        $this->templateParameters['record'] = $this->getByPrimaryKey($this->primaryKeyValue);
        // render template
        $this->renderTemplate(sprintf('%s/%s/save-form', AREA, $this->name));
    }
511405
function( targetFormIdAndName, fieldsToProtect ) {
					var released = false;
					var self = this;

					// Released form, are not started anymore. Fix for ajax loaded forms.
					params.started[ self.getInstanceIdentifier() ] = false;

					fieldsToProtect.each( function() {
						if ( $.inArray( this, self.options.excludeFields ) !== -1 ) {
							// Returning non-false is the same as a continue statement in a for loop; it will skip immediately to the next iteration.
							return true;
						}
						var field = $( this );
						var prefix = (self.options.locationBased ? self.href : "") + targetFormIdAndName + getElementIdentifier( field ) + self.options.customKeySuffix;
						self.browserStorage.remove( prefix );
						released = true;
					} );

					if ( released ) {
						self.options.onRelease.call( self );
					}
				}
722984
def save_form(self, request, form, change):
        
        obj = form.save(commit=False)
        if obj.user_id is None:
            obj.user = request.user
        return super(OwnableAdmin, self).save_form(request, form, change)
809383
public static void setFieldProtected(FormModel formModel, String fieldName, boolean protectedField) {
        FieldMetadata metaData = formModel.getFieldMetadata(fieldName);
        metaData.getAllUserMetadata().put(PROTECTED_FIELD, Boolean.valueOf(protectedField));
    }
848634
public function updateEditForm(Form $form) {
        $record=$form->getRecord();
        if($record) {
            $kapostRefID=$record->KapostRefID;
            if(empty($kapostRefID)) {
                return;
            }

            //Make the fields all read only
            $oldFields=$form->Fields();
            $form->setFields($oldFields->makeReadonly());
            
            //Make the fields that should be non-readonly editable again
            foreach($record->config()->non_readonly_fields as $fieldName) {
                $oldField=$oldFields->dataFieldByName($fieldName);
                if($oldField) {
                    $form->Fields()->replaceField($fieldName, $oldField);
                }
            }
            
            
            //Loop through the wysiwyg fields that need to be made safe and sanitize their html
            foreach($record->config()->make_safe_wysiwyg_fields as $fieldName) {
                $field=$form->Fields()->dataFieldByName($fieldName);
                if($field) {
                    $field->setName($field->getName().'_safe');
                    $field->setValue($this->sanitizeHTML($field->Value()));
                }
            }
        }
    }
1082138
protected function setFormData()
    {
        foreach ($this->validFields as $field => $params) {
            if (isset($params["rename"])) {
                $field = $params["rename"];
            }
            if ($params['type'] == "single") {
                if (isset($this->fieldData[$field])) {
                    $this->formData[$field] = $this->fieldData[$field];
                }
            } elseif ($params['type'] == "product") {
                if (!isset($this->formData[$field])) {
                    $this->formData[$field] = array();
                }
                foreach ($this->products as $num => $product) {
                    if (isset($product[$params["paramName"]])) {
                        $this->formData[$field][$num] = $product[$params["paramName"]];
                    }
                }
            }
        }
    }
575692
def stored_fields(field_name, dynamic_field_name = nil)
      @stored_field_factories_cache[field_name.to_sym].map do |field_factory|
        if dynamic_field_name
          field_factory.build(dynamic_field_name)
        else
          field_factory.build
        end
      end
    end
933727
@SuppressWarnings({"rawtypes", "unchecked"})
    private void initializeFormFieldWidget(final I_CmsFormField formField) {

        final I_CmsFormWidget widget = formField.getWidget();
        if (widget instanceof HasValueChangeHandlers) {
            ((HasValueChangeHandlers)widget).addValueChangeHandler(new ValueChangeHandler() {

                /**
                 * @see com.google.gwt.event.logical.shared.ValueChangeHandler#onValueChange(ValueChangeEvent event)
                 */
                public void onValueChange(ValueChangeEvent event) {

                    boolean inhibitValidation = false;
                    if (event instanceof CmsExtendedValueChangeEvent) {
                        CmsExtendedValueChangeEvent extEvent = (CmsExtendedValueChangeEvent)event;
                        inhibitValidation = extEvent.isInhibitValidation();
                    }
                    Object eventValue = event.getValue();
                    if ((eventValue instanceof String) || (event.getValue() == null)) {
                        // only makes sense for strings
                        defaultHandleValueChange(formField, (String)(event.getValue()), inhibitValidation);
                    } else if (eventValue instanceof Date) {
                        defaultHandleValueChange(formField, "" + ((Date)eventValue).getTime(), inhibitValidation);
                    } else if (eventValue instanceof Boolean) {
                        defaultHandleValueChange(formField, "" + eventValue, inhibitValidation);
                    }

                }
            });
        }

        if (widget instanceof HasKeyPressHandlers) {
            ((HasKeyPressHandlers)widget).addKeyPressHandler(new KeyPressHandler() {

                /**
                 * @see com.google.gwt.event.dom.client.KeyPressHandler#onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent)
                 */
                public void onKeyPress(KeyPressEvent event) {

                    int keyCode = event.getNativeEvent().getKeyCode();
                    defaultHandleKeyPress(formField, keyCode);
                }
            });
        }
    }
1048658
def field2write_only(self, field, **kwargs):
        
        attributes = {}
        if field.load_only and self.openapi_version.major >= 3:
            attributes["writeOnly"] = True
        return attributes
1005429
def formfield(self, **kwargs):
        
        if self.plugin_class:
            self._choices = self.plugin_class.get_all_choices(field=self)
        return super(TemplateNameField, self).formfield(**kwargs)
924666
public function define_form_specific($form) {
        // Select whether or not this should be checked by default.
        $form->addElement('selectyesno', 'defaultdata', get_string('profiledefaultchecked', 'admin'));
        $form->setDefault('defaultdata', 0); // Defaults to 'no'.
        $form->setType('defaultdata', PARAM_BOOL);
    }