Class: FieldModel

Drupal.quickedit.FieldModel(options)

new FieldModel(options)

State of an in-place editable field in the DOM.

Parameters:
Name Type Description
options object

Options for the field model.

Source:

Extends

Members

(static) states :Array.<string>

Sequence of all possible states a field can be in during quickediting.

Type:
  • Array.<string>
Source:

acceptStateChange

Callback function for validating changes between states. Receives the previous state, new state, context, and a callback.

Source:

defaults :object

Type:
  • object
Source:

el

The DOM element that represents this field. It may seem bizarre to have a DOM element in a Backbone Model, but we need to be able to map fields in the DOM to FieldModels in memory.

Source:

entity

A Drupal.quickedit.EntityModel. Its "fields" attribute, which is a FieldCollection, is automatically updated to include this FieldModel.

Source:

fieldID

A field ID, of the form <entity type>/<id>/<field name>/<language>/<view mode>

Source:
Example
"node/1/field_tags/und/full"

html

The full HTML representation of this field (with the element that has the data-quickedit-field-id as the outer element). Used to propagate changes from this field to other instances of the same field storage.

Source:

htmlForOtherViewModes

An object containing the full HTML representations (values) of other view modes (keys) of this field, for other instances of this field displayed in a different view mode.

Source:

id

The unique ID of this field within its entity instance on the page, of the form <entity type>/<id>/<field name>/<language>/<view mode>[entity instance ID].

Source:
Example
"node/1/field_tags/und/full[0]"

inTempStore

Is tracked by the EntityModel, is mirrored here solely for decorative purposes: so that FieldDecorationView.renderChanged() can react to it.

Source:

isChanged

The field is currently in the 'changed' state or one of the following states in which the field is still changed.

Source:

logicalFieldID

A logical field ID, of the form <entity type>/<id>/<field name>/<language>, i.e. the fieldID without the view mode, to be able to identify other instances of the same field on the page but rendered in a different view mode.

Source:
Example
"node/1/field_tags/und".

metadata

This field's metadata as returned by the QuickEditController::metadata().

Source:

state

In-place editing state of this field. Defaults to the initial state. Possible values: Drupal.quickedit.FieldModel.states.

Source:

Methods

(static) followsStateSequence(from, to) → {bool}

Indicates whether the 'from' state comes before the 'to' state.

Parameters:
Name Type Description
from string

One of Drupal.quickedit.FieldModel.states.

to string

One of Drupal.quickedit.FieldModel.states.

Source:
Returns:

Whether the 'from' state comes before the 'to' state.

Type
bool

destroy(options)

Destroys the field model.

Parameters:
Name Type Description
options object

Options for the field model.

Source:

findOtherViewModes() → {Array}

Find other instances of this field with different view modes.

Source:
Returns:

An array containing view mode IDs.

Type
Array

getEntityID() → {string}

Extracts the entity ID from this field's ID.

Source:
Returns:

An entity ID: a string of the format <entity type>/<id>.

Type
string

getViewMode() → {string}

Extracts the view mode ID from this field's ID.

Source:
Returns:

A view mode ID.

Type
string

set(key, val, optionsopt) → {*}

Set a value on the model

Parameters:
Name Type Attributes Description
key object | string

The key to set a value for.

val *

The value to set.

options object <optional>

Options for the model.

Inherited From:
Source:
Returns:

The result of Backbone.Model.prototype.set with the specified parameters.

Type
*

sync()

{@inheritdoc}

Source:

validate(attrs, options) → {string}

Validate function for the field model.

Parameters:
Name Type Description
attrs object

The attributes changes in the save or set call.

options object

An object with the following option:

Properties
Name Type Attributes Description
reason string <optional>

A string that conveys a particular reason to allow for an exceptional state change.

accept-field-states Array

An array of strings that represent field states that the entities must be in to validate. For example, if accept-field-states is ['candidate', 'highlighted'], then all the fields of the entity must be in either of these two states for the save or set call to validate and proceed.

Source:
Returns:

A string to say something about the state of the field model.

Type
string