2

Does anyone have an example of how I add an Entity Select (Specifically a term reference) to a custom composite?

Here's the code I've tired. The field with the title shows up but no select.

$elements['test_tax'] = [
  '#type' => 'entity_select',
  '#title' => t('Test Taxonomy'),
  '#target_type' => 'taxonomy_term',
  '#selection_handler' => 'default:taxonomy_term',
  '#selection_settings' => [
    'target_bundles' => [
      'my_terms' => 'my_terms'
    ],
    'sort' => [
      'field' => 'name',
      'direction' => 'ASC'
    ]
  ] 
];

I'm a front-end guy so I'm a bit out of my element in php...

2

I think you just need to change...

'#type' => 'entity_select',

...to...

'#type' => 'webform_entity_select',

In the Webform YAML source editor we are hiding the 'webform_*' prefixes, within custom code they have to included.

@see https://cgit.drupalcode.org/webform/tree/src/Element/WebformEntitySelect.php

  • That was it! Thanks for making the example module for composites as well. Even a as a non-php dev I was able to get it pretty close. Major kudo's to you guys. – Brad O Feb 9 '18 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.