new FieldModel(options)
State of an in-place editable field in the DOM.
Parameters:
Name | Type | Description |
---|---|---|
options |
object | Options for the field model. |
Extends
Members
(static) states :Array.<string>
Sequence of all possible states a field can be in during quickediting.
Type:
- Array.<string>
acceptStateChange
Callback function for validating changes between states. Receives the previous state, new state, context, and a callback.
defaults :object
Type:
- object
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.
entity
A Drupal.quickedit.EntityModel
. Its "fields" attribute, which
is a FieldCollection, is automatically updated to include this
FieldModel.
fieldID
A field ID, of the form
<entity type>/<id>/<field name>/<language>/<view mode>
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.
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.
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]
.
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.
isChanged
The field is currently in the 'changed' state or one of the following states in which the field is still changed.
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.
Example
"node/1/field_tags/und".
metadata
This field's metadata as returned by the QuickEditController::metadata().
state
In-place editing state of this field. Defaults to the initial state.
Possible values: Drupal.quickedit.FieldModel.states
.
Methods
(static) followsStateSequence(from, to) → {bool}
Indicates whether the 'from' state comes before the 'to' state.
Parameters:
Name | Type | Description |
---|---|---|
from |
string | |
to |
string |
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. |
findOtherViewModes() → {Array}
Find other instances of this field with different view modes.
Returns:
An array containing view mode IDs.
- Type
- Array
getEntityID() → {string}
Extracts the entity ID from this field's ID.
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.
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}
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
|
Returns:
A string to say something about the state of the field model.
- Type
- string