Element Entity Field

Categories

Component ID

2846079

Component name

Element Entity Field

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

Provides a Form API element type 'entity_field' for getting / setting a field from an entity.

eg. given a page $node, with field 'field_foo':

$form['title'] = array(
  '#type' => 'entity_field',
  '#settings' => array(
      'field_names' => array('field_foo'),
      'entity' => $node,
    ),
);

will attach to $form the rendered field widget for the field_foo instance attached to page nodes.

Additionally, the field can be rendered with an empty value to create an entity on submit:

$form['title'] = array(
  '#type' => 'entity_field',
  '#settings' => array(
      'entity_type' => 'node',
      'bundle' => 'page',
      'field_names' => array('field_foo'),
    ),
);