public function ManagerForm::createField in Hashtags 8
Create a hashtags taxonomy term field
Parameters
$field_storage:
$bundle:
$label:
array $term_bundles:
Return value
\Drupal\Core\Entity\EntityInterface|static
1 call to ManagerForm::createField()
- ManagerForm::addField in src/
Form/ ManagerForm.php
File
- src/
Form/ ManagerForm.php, line 173
Class
Namespace
Drupal\hashtags\FormCode
public function createField($field_storage, $bundle, $label, $term_bundles = [
'hashtags' => 'hashtags',
]) {
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $bundle,
'label' => $label,
'required' => false,
'field_type' => 'entity_reference',
'settings' => [
'handler' => 'default:taxonomy_term',
'handler_settings' => [
'target_bundles' => $term_bundles,
'sort' => [
'field' => 'name',
'direction' => 'asc',
],
'auto_create' => true,
'auto_create_bundle' => '',
],
],
]);
$field
->save();
return $field;
}