0

I have an entity reference field as a select list. How can I add other options there if selected user can add a text to a text field? I am using Drupal 7.

Thanks,

Emad Samir Zaki
  • 393
  • 2
  • 10

1 Answers1

0

1.Add new text field called "other" on you create node form and make it hidden by default (form alter prefix & suffix with div with "hidden" class)

2.Do a form alter for that content type - alter referenced field option by adding new item in array called "other".

3.Using AJAX show newly created field if user select "other" in drop down by removing the "hidden" class.

Beyer
  • 301
  • 1
  • 9
  • I do not think this would work as Drupal will try to save the "other" value as an entity reference and crash while trying. I think the best way is to develop a custom field type but it's more complicated. – Renrhaf Jul 30 '19 at 19:30