I have Entity reference field (taxonomy terms ) in node form.
I have checked the option (Create referenced entities if they don't already exist) so that users can create new taxonomy terms in field of node form i.e.: on creation on node new terms creation is allowed.
Looks like below in Node Form:
But I want to alter this and make restricted to certain roles. So that user with particular role should not be able to create new terms and must select from existing node.
My field is core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
While going thorugh code it seems under :
[#selection_settings] => Array
(
[target_bundles] => Array
(
[topic] => topic
)
[sort] => Array
(
[field] => name
[direction] => asc
)
[auto_create] => 1
[auto_create_bundle] =>
[match_operator] => CONTAINS
)
[auto_create] => 1 I tried to alter this by adding contain of user role in node form alter, but not its not working the value get changed.
Please suggest !
Update : Please see @ssibal
drupal config-list field.field.node.link.field_topic2
field.field.node.link.field_topic2
uuid: f3c818dd-b5cd-4a73-af88-c20c1d0e24c3
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_topic2
- node.type.link
- taxonomy.vocabulary.topic
id: node.link.field_topic2
field_name: field_topic2
entity_type: node
bundle: link
label: Topic
description: "Sätt flera olika ämnen, separera dem med kommatecken och inled med stor bokstav.\r\n<br>\r\nExempel: SEB, Fraktionella reserver, Svågerkapitalism"
required: true
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
topic: topic
sort:
field: name
direction: asc
auto_create: true
auto_create_bundle: ''
field_type: entity_reference