0

I have a field called booked user and two types of content types, event-type-A and event-type-B.

I am referring to the same field from both content types. However, along the process I figured out that I want to have multiple values for this field in event type-A and single value for event-type-B. Initially both had multiple values.

Whenever I change the field settings in one content type, it also changes in the other.

How can I overcome this? Considering that I have content created in type-B and I can not really add a new field to replace that one, cause I will lose all the previous field content for that user.

1 Answer 1

1

The solution a colleague proposed is to add the following code in the hook_form_alter():

$language = $form['field_user']['#language'];
$form['field_user'][$language]['#multiple'] = 0;

If you want to be a bit more aggressive on data consistency you can also hook into the form validator and check that the correct number of values is inserted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.