0

I would like to attach a textfield field to the video field. How can I go about doing that programmatically?

How do you attach a field of a field?

2 Answers 2

1

You can use hook_form_alter(), there is no any built-in option to do that.

You can also use the Field collection module to create a new field collection with a text field, and the video field.

Provides a field-collection field, to which any number of fields can be attached.

A field collection is internally represented as an entity, which is embedded in the host entity. Thus, if desired field collections may be viewed and edited separately too.

0
0

You can implement hook_field_widget_form_alter() to add a #process function to the widget. This is what the Image field does in image_field_widget_form(), by adding image_field_widget_process() as #process function.

// Add all extra functionality provided by the image widget.
$elements[$delta]['#process'][] = 'image_field_widget_process';

If you need to save the content of the form field you add, and the field doesn't provide a database field to save it, there is nothing much you can do, until No hook_field_schema_alter() gets implemented for Drupal 7 too.

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.