Skip to content
entity

DruxtField

View source on GitHub

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>
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."
/>

.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


.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


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

ParamTypeDescription
contextobjectThe module component ViewModel.

.propsData(context) ⇒ PropsData

Provides propsData for the DruxtWrapper.

Kind: static method of druxt

ParamTypeDescription
contextobjectThe 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

NameTypeDescription
modelobjectThe 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

ParamTypeDescription
componentstringThe 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

ParamTypeDescription
errorsArray.<object>JSON:API errors.
relationshipbooleanField relationship status.
schemaobjectDrupal Field schema information.
valueobjectThe 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

ParamTypeDescription
field-#functionA slot per field item, e.g. field-0.
labelfunctionThe field label.
label-abovefunctionThe field label, if label position is 'above'.
label-inlinefunctionThe field label, if label position is 'inline'.
defaultfunctionThe appropriate label and fields.

Components : Array.<object>

Kind: global typedef
Properties

NameTypeDescription
globalbooleanComponent global registration state.
namestringThe component name.
partsArray.<string>The component naming parts.

Example

[{
  global: true,
  pascal: 'DruxtTestModuleWrapper',
  parts: ['Wrapper'],
}]

ComponentData : object

Kind: global typedef
Properties

NameTypeDefaultDescription
$attrsobjectpropsData not registered by the Wrapper component.
isstring"DruxtWrapper"The Wrapper component name.
optionsArray.<string>The Wrapper component options.
propsobjectpropsData registered by the Wrapper component.
propsDataobjectThe component propsData object.
settingsobjectDruxt 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

NameTypeDescription
druxtobjectDruxt settings object for use by Druxt module.
propsobjectRegistered props oject.

Example

{
  druxt: { fooBar: true },
  props: {
    foo: {
      type: String,
      default: '',
    }
  }
}