DruxtField
Modules
- 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> The list of candidate Wrapper components, with naming parts and global registration state.
- ComponentData :
object The Wrapper component and propsData to be rendered.
- WrapperData :
object Druxt settings and registered props retrieved from the Wrapper component.
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(vm)
- 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:2.0.0. Use the component suggestion system instead.
Kind: static property of props
See: https://app.feature-docgen-deprecations.druxtjs-org.au2.amazee.io/modules/entity/deprecations
.value : array | boolean | number | object | string
The Field value.
Kind: static property of props
Model:
.langcode
The resource langcode.
Kind: static property of props
Example
<DruxtField langcode="en" />
.v-model
The Field value.
Kind: static property of props
.wrapper
The wrapper component configuration.
Used to set the wrapper component, class, style and propsData.
Kind: static property of props
Example
<DruxtField
:wrapper="{
component: 'BCard',
class: 'article-card',
propsData: { noBody: true }
}"
/>
.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. |
| context.schema | object | The DruxtSchema field schema object. |
.propsData(context) ⇒ PropsData
Provides propsData for the DruxtWrapper.
Kind: static method of druxt
| Param | Type | Description |
|---|---|---|
| context | object | The module component ViewModel. |
| context.errors | Array.<object> | Field errors from the form submission response. |
| context.model | Array | boolean | number | object | string | The field value. |
| context.relationship | boolean | true if this field is a JSON:API relationship. |
| context.schema | object | The DruxtSchema field schema object. |
.slots(h) ⇒ 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.
| Param | Type | Description |
|---|---|---|
| h | function | The Vue createElement function. |
Example (DruxtFieldSchemaType.vue)
<template>
<div>
<slot name="label" />
<slot name="field-0" />
</div>
</template>
.data(vm)
Kind: static method of DruxtField
| Param | Type | Description |
|---|---|---|
| vm | object | The component ViewModel. |
| vm.value | array | boolean | number | object | string | The Field value. |
Properties
| Name | Type | Description |
|---|---|---|
| model | object | The model object. |
.error(err, [context])
Sets the component to render a DruxtDebug error message.
Kind: instance method of DruxtField
| Param | Type | Description |
|---|---|---|
| err | object | The error object. |
| [context] | object | Error context; carries the wrapper component data where the failure knows it. |
.getModuleComponents() ⇒ Components
Get list of module wrapper components.
Kind: instance method of DruxtField
.getModulePropsData(wrapperProps) ⇒ object
Get module propsData via modules druxt.propsData() callback.
Kind: instance method of DruxtField
| Param | Type | Description |
|---|---|---|
| wrapperProps | object | Props registered by the Wrapper component. |
Example
{
$attrs: { entity: {}, fields: {}, langcode: 'en', schema: {} },
props: { value: {} },
propsData: { entity: {}, fields: {}, langcode: 'en', schema: {}, value: {} },
}
.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/components/DruxtModule.vue'
export default {
name: 'DruxtCustomModule',
extends: DruxtModule,
async fetch() {
await DruxtModule.fetch.call(this)
}
druxt: {
componentOptions: () => ([['Default']]),
propsData: ({ model }) => ({ value: model }),
}
}
.lang(vm) ⇒ 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.
| Param | Type | Description |
|---|---|---|
| vm | object | The component ViewModel. |
| vm.langcode | string | The langcode prop. |
| vm.$route | object | The current route. |
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 |
|---|---|---|
| * | 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>
The list of candidate Wrapper components, with naming parts and global registration state.
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,
name: 'DruxtEntityNodeArticleDefault',
parts: ['NodeArticle', 'Default'],
}]
ComponentData : object
The Wrapper component and propsData to be rendered.
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: { entity: {}, fields: {}, schema: {} },
is: 'DruxtEntityNodeArticleDefault',
options: [
'DruxtEntityNodeArticleDefault',
'DruxtEntityDefault',
],
props: { value: {} },
propsData: {
entity: {},
fields: {},
schema: {},
value: {},
},
settings: { query: {} },
}
WrapperData : object
Druxt settings and registered props retrieved from the Wrapper component.
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| druxt | object | Druxt settings object for use by Druxt module. |
| props | object | Registered props oject. |
Example
{
druxt: { query: { fields: ['path', 'title'] } },
props: {
value: {
type: Object,
default: () => ({}),
}
}
}