Hello,
I want to use the "Icon Select" widget in a custom form, but I can't find how to do it.
The purpose is to display the icon selector as when setting the widget in the form display mode from the back office.
Here is the configuration of my field in the form:
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class MyCustomForm extends FormBase {
public function getFormId()
{
return 'my_custom_form_id';
}
public function buildForm(array $form, FormStateInterface $form_state)
{
// ... other fields ...
$form['icon_choice'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#selection_settings' => [
'target_bundles' => [ 'icons' ]
]
];
// ... other fields ...
return $form;
}
I found instructions on the web to create a widget and use it from the Drupal back office interface, but I don't think I understood how to do it in programming in the fields of my custom form.
Thank you in advance for your help.
Germain.
Closed: outdated
1.1
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.