1

Is it possible solved with field api this task? I need to add new elements to an existing field. For example there is a field image. I create a widget and add a checkbox

/**
 * Implements hook_field_widget_form().
 */
function mymodule_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $elements = image_field_widget_form($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
  foreach (element_children($elements) as $delta) {

    $elements[$delta]['#process'][] = 'custom_widget_process';

  }
  return $elements;




function custom_widget_process($element, &$form_state, $form) {
  $element['myelement'] = array(
    '#type' => 'checkbox',
    '#title' => t('My checkbox.'),
  );
  return $element;
}

enter image description here

How do I save the value of the checkbox? (If I have a table for it)

Can I add additional column into an existing image field scheme? (hook_field_schema_alter - not exist)

1 Answer 1

0

File Entity module allows you to add extra fields to file fields.

File entity provides interfaces for managing files. It also extends the core file entity, allowing files to be fieldable, grouped into types, viewed (using display modes) and formatted using field formatters.

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.