# Class: BaseEditorView

## module:core.form.editors.base. BaseEditorView

Base class for all editors in the library. While implementing editors, inherit from one of the following classes which in turn are inherited from this one:

- `BaseCollectionEditorView`
- `BaseCompositeEditorView`
- `BaseLayoutEditorView`
- `BaseItemEditorView`

Possible events:

- `'change' (thisEditorView)` - fires when the value inside the editor is changed. This event doesn't imply any change in model (!).
- `'focus' (thisEditorView)` - fire when the editor gets the focus.
- `'blur' (thisEditorView)` - fire when the editor loses the focus.
- `'enabled' (enabled)` - fires when the property `enabled` is changed.
- `'readonly' (readonly)` - fires when the property `readonly` is changed.
- `'<key>:committed' (thisEditorView, model, value)` - fires when the value is committed into the model.
- `'value:committed' (thisEditorView, model, key, value)` - fires when the value is committed into the model.

#### new BaseEditorView(options)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Object | Options object. ###### Properties
  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `autocommit` | Boolean | <optional> | false | Indicates whether to call `commit()` method on the value change.
  `forceCommit` | Boolean | <optional> | false | Indicated whether to commit the value into the model if editors validation has failed (not recommended).
  `enabled` | Boolean | <optional> | true | The initial value of `enabled` flag. Can be changed later on by calling `setEnabled()` method.
  `readonly` | Boolean | <optional> | false | The initial value of `readonly` flag. Can be changed later on by calling `setReadonly()` method.
  `model` | Boolean | <optional> |  | A model which contains an attributes edited by this editor. Can only be used if the editor is created standalone (without a form). Must be used together with `key` options.
  `key` | Boolean | <optional> |  | The name of an attribute in `options.model` edited by this editor. Can only be used if the editor is created standalone (without a form). Must be used together with `model` options.
  `validators` | Function[] | <optional> |  | An array of validator function which look like the following: `function(value, formValues) -> ({type, message}|undefined)`
  `schema` | Object | <optional> |  | When created implicitly by form, all the editor options are passed through this option. Не использовать явно.

### Extends

- Marionette.View

### Members

#### hasFocus

  Indicates whether the editor has focus.

### Methods

#### blur()

  Clears the focus.

#### commit( [options])

  Update the model with the internal editor's value.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `options` | Object | <optional> | Options to pass to model.set(). ###### Properties
  Name | Type | Argument | Description
  --- | --- | --- | ---
  `validate` | Boolean | <optional> | Set to true to trigger built-in model validation.

  ##### Returns:

  Returns an error object `{ type, message }` if validation fails and `options.forceCommit` is turned off. `undefined` otherwise.
  Type
    Object | undefined

#### focus()

  Sets the focus onto this editor.

#### getEnabled()

  Returns the value of `enabled` flag.

  ##### Returns:

  Type
    Boolean

#### getModelValue()

  Retrieves actual value of the bound attribute from the model.

  ##### Returns:

  Type
    *

#### getReadonly()

  Returns the value of `readonly` flag.

  ##### Returns:

  Type
    Boolean

#### getValue()

  Returns internal editor's value.

  ##### Returns:

  Type
    *

#### setEnabled(enabled)

  Sets a new value of `enabled` flag. While disabled, the editor's value cannot be changed or copied by the user. It's implied that the value doesn't make sense.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `enabled` | Boolean | New flag value.

#### setReadonly(readonly)

  Sets a new value of `readonly` flag. While readonly, the editor's value cannot be changed but can be copied by the user.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `readonly` | Boolean | New flag value.

#### setValue(value)

  Sets new internal editor's value.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | * | The new value.

#### updateValue()

  Manually updated editor's internal value with the value from `this.model.get(this.key)`. Shouldn't be called normally. The method is called internally on model's `change` event.

#### validate()

  Check validity with built-in validator functions (initially passed into constructor options).

  ##### Returns:

  Returns an error object `{ type, message }` if validation fails. `undefined` otherwise.
  Type
    Object | undefined

#### Search results