0

i have a problem regarding fields of type list.

The scenario is the following. I have a content type with several fields, among them a field of type list. This field have 3 values ("1" to "3"). I want any of those 3 values to belong only in ONE node of this specific content type.

In other words, if a node of that content type has the value "1" in that field, i want that value to be "disabled" when creating new nodes of that content type (so, only available options to be "2" and "3").

Do you have any ideas? Is it possible at all?

Thanks in advance!

  • What is the purpose of this usage. – Jimmy Ko Nov 18 '16 at 12:33
0

you need to build a custom module in which you implement hook_form_FORM_ID_alter. since we're dealing with node create/edit forms, try yourmodule_form_yourcontenttype_node_form_alter().

(you could go for hook_form_alter(), but that would yield less performance, especially since you have a query to run.)

your implementation should include a query for that specific field, probably the table field_data_field_yourfield. narrow it by bundle and if it returns any entity_id, that's the one you're filtering out of your dropdown.

here's a few links to help you sort things out:

please write back if it works. good luck!

cheers, Luco

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.