DruxtField
View source on GitHubModules
- DruxtField
Renders a Drupal Field using Drupals by field type and formatter settings.
Typedefs
- ComponentOptions :
Array.<array> Provides the available naming options for the Wrapper component.
- PropsData :
object Provides propsData for use in the Wrapper component.
- ScopedSlots :
object Provides scoped slots for use in the Wrapper component.
- Components :
Array.<object> - ComponentData :
object - WrapperData :
object
DruxtField
Renders a Drupal Field using Drupals by field type and formatter settings.
Example
<DruxtField
:schema="{
id: 'field_summary',
label: {
position: 'above',
text: 'Summary',
},
type: 'basic_string'
}"
value="A wholesome pasta bake is the ultimate comfort food. This delicious bake is super quick to prepare and an ideal midweek meal for all the family."
/>
- DruxtField
- static
- .props
- .computed
- .data :
array|boolean|number|object|string - .isBoolean :
boolean - .isDateTime :
boolean - .isFile :
boolean - .isImage :
boolean - .isLink :
boolean - .isMultiple :
boolean - .isText :
boolean - .label :
object
- .data :
- .druxt
- .data()
- instance
- static
- static
.props
Kind: static property of DruxtField
.errors : Array.<object>
JSON:API errors.
Kind: static property of props
.relationship : boolean
true if this field is a JSON:API relationship.
Kind: static property of props
Default: false
.schema : object
Drupal Field schema object.
Kind: static property of props
.options
Deprecated: in druxt-entity:0.5.0 and is removed from druxt-entity:1.0.0. Use the component suggestion system instead.
Kind: static property of props
See: https://druxtjs.org/modules/entity/deprecations
.value : array | boolean | number | object | string
The Field value.
Kind: static property of props
Model:
.langcode : string
The resource langcode.
Kind: static property of props
Default: "undefined"
Example
<DruxtField langcode="en" />
.v-model : (array | boolean | number | object | string)
The Field value.
Kind: static property of props
Default: undefined
.wrapper : (boolean | object)
The wrapper component configuration.
Used to set the wrapper component, class, style and propsData.
Kind: static property of props
Default: () => undefined
Example
<DruxtField
:wrapper="{
component: 'MyWrapper',
class: 'wrapper',
propsData: { foo: 'bar' }
}"
/>
.computed
Kind: static property of DruxtField
- .computed
- .data :
array|boolean|number|object|string - .isBoolean :
boolean - .isDateTime :
boolean - .isFile :
boolean - .isImage :
boolean - .isLink :
boolean - .isMultiple :
boolean - .isText :
boolean - .label :
object
- .data :
.data : array | boolean | number | object | string
The Field data.
Kind: static property of computed
.isBoolean : boolean
Field is Boolean?
Kind: static property of computed
.isDateTime : boolean
Field is DateTime?
Kind: static property of computed
.isFile : boolean
Field is File?
Kind: static property of computed
.isImage : boolean
Field is Image?
Kind: static property of computed
.isLink : boolean
Field is Link?
Kind: static property of computed
.isMultiple : boolean
Field is multi-cardinality.
Kind: static property of computed
.isText : boolean
Field is Text?
Kind: static property of computed
.label : object
The Field label display settings.
Kind: static property of computed
Default: { position: 'hidden' }
.druxt
DruxtModule settings
Kind: static property of DruxtField
.template
Druxt development template tool configuration.
Kind: static property of druxt
.componentOptions(context) ⇒ ComponentOptions
Provides the available component naming options for the Druxt Wrapper.
Kind: static method of druxt
| Param | Type | Description |
|---|---|---|
| context | object | The module component ViewModel. |
.propsData(context) ⇒ PropsData
Provides propsData for the DruxtWrapper.
Kind: static method of druxt
| Param | Type | Description |
|---|---|---|
| context | object | The module component ViewModel. |
.slots() ⇒ ScopedSlots
Provides the scoped slots object for the Module render function.
A scoped slot per field item is provided, with support for:
- File, Image, Link, Number, Text and other View fields.
- Boolean, Date/Time, Text and other Form fields.
- Entity references.
A scoped slot is provided for the label, as well as label-above and label-inline depending on the field schema.
A default slot is provided with debug information if Nuxt is in development mode.
Kind: static method of druxt
Returns: ScopedSlots - The Scoped slots object.
Example (DruxtFieldSchemaType.vue)
<template>
<div>
<slot name="label" />
<slot name="field-0" />
</div>
</template>
.data()
Kind: static method of DruxtField
Properties
| Name | Type | Description |
|---|---|---|
| model | object | The model object. |
.error()
Sets the component to render a DruxtDebug error message.
Kind: instance method of DruxtField
.getModuleComponents() ⇒ Components
Get list of module wrapper components.
Kind: instance method of DruxtField
.getModulePropsData() ⇒ object
Get module propsData via modules druxt.propsData() callback.
Kind: instance method of DruxtField
Example
{
bar: 'foo',
foo: 'bar',
}
.getScopedSlots() ⇒ object
Gets a Druxt modules scoped slots, and if there's no default slots, provides a develop mode debug default or passes through to a default template.
Kind: instance method of DruxtField
.getWrapperData(component) ⇒ WrapperData
Get wrapper component data.
Kind: instance method of DruxtField
| Param | Type | Description |
|---|---|---|
| component | string | The Wrapper component name. |
.methods
Kind: static property of DruxtField
.fetch()
Loads the Druxt module data and applies a wrapper component as required.
Important: If your component has an existing fetch method, you must manually invoke
the DruxtModule.fetch() hook.
Kind: static method of DruxtField
Example (Manually invoking DruxtModule.fetch().)
import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
export default {
name: 'DruxtTestModule',
extends: DruxtModule,
async fetch() {
await DruxtModule.fetch.call(this)
}
druxt: {
componentOptions: () => ([['wrapper']]),
propsData: (ctx) => ({
bar: ctx.bar,
foo: ctx.foo,
}),
}
}
.lang() ⇒ string
The current language code: the langcode prop if set, otherwise the
route's langcode metadata.
Used by Druxt modules to fetch the correct resource translation.
Kind: static method of DruxtField
Returns: string - The current language code.
ComponentOptions : Array.<array>
Provides the available naming options for the Wrapper component.
Kind: global typedef
Example
[
'DruxtField[Type][Id][SchemaType][Langcode]',
'DruxtField[Type][Id][SchemaType]',
'DruxtField[Type][Id][Langcode]',
'DruxtField[Type][Id]',
'DruxtField[Type][SchemaType][Langcode]',
'DruxtField[Type][SchemaType]',
'DruxtField[Default][SchemaType][Langcode]',
'DruxtField[Default][SchemaType]',
'DruxtField[Type][Langcode]',
'DruxtField[Type]',
'DruxtField[Default][Langcode]',
'DruxtField[Default]',
]
Example (Media field)
[
'DruxtFieldEntityReferenceEntityViewFieldMediaImageViewEn',
'DruxtFieldEntityReferenceEntityViewFieldMediaImageView',
'DruxtFieldEntityReferenceEntityViewFieldMediaImageEn',
'DruxtFieldEntityReferenceEntityViewFieldMediaImage',
'DruxtFieldEntityReferenceEntityViewViewEn',
'DruxtFieldEntityReferenceEntityViewView',
'DruxtFieldDefaultViewEn',
'DruxtFieldDefaultView',
'DruxtFieldEntityReferenceEntityViewEn',
'DruxtFieldEntityReferenceEntityView',
'DruxtFieldDefaultEn',
'DruxtFieldDefault',
]
PropsData : object
Provides propsData for use in the Wrapper component.
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| errors | Array.<object> | JSON:API errors. |
| relationship | boolean | Field relationship status. |
| schema | object | Drupal Field schema information. |
| value | object | The Field value. |
Example
{
errors: [],
relationship: true,
schema: {
config: {},
description: '',
id: 'field_media_image',
label: {},
required: true,
settings: {},
thirdPartySettings: [],
type: 'entity_reference_entity_view',
weight: 4,
},
value: {
data: {
id: '71a90e86-55b6-40fe-b77d-552dca1bee77',
type: 'media--image',
},
links: {},
},
}
ScopedSlots : object
Provides scoped slots for use in the Wrapper component.
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| field-# | function | A slot per field item, e.g. field-0. |
| label | function | The field label. |
| label-above | function | The field label, if label position is 'above'. |
| label-inline | function | The field label, if label position is 'inline'. |
| default | function | The appropriate label and fields. |
Components : Array.<object>
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| global | boolean | Component global registration state. |
| name | string | The component name. |
| parts | Array.<string> | The component naming parts. |
Example
[{
global: true,
pascal: 'DruxtTestModuleWrapper',
parts: ['Wrapper'],
}]
ComponentData : object
Kind: global typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| $attrs | object | propsData not registered by the Wrapper component. | |
| is | string | "DruxtWrapper" | The Wrapper component name. |
| options | Array.<string> | The Wrapper component options. | |
| props | object | propsData registered by the Wrapper component. | |
| propsData | object | The component propsData object. | |
| settings | object | Druxt settings object provided by the Wrapper component. |
Example
{
$attrs: { bar: 'foo' },
is: 'DruxtTestModuleWrapper',
options: [
'DruxtTestModuleWrapper',
],
props: { foo: 'bar' },
propsData: {
bar: 'foo',
foo: 'bar',
},
settings: { fooBar: true },
}
WrapperData : object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| druxt | object | Druxt settings object for use by Druxt module. |
| props | object | Registered props oject. |
Example
{
druxt: { fooBar: true },
props: {
foo: {
type: String,
default: '',
}
}
}