0

I have a content type, this content type has a Field Collection with cardinality(delta) value 1.

  • I want to alter it dynamically, when the node add form is rendered.

  • Each node add form has it different cardinality(delta) value.

Please any one help me to solve it in Drupal 7.

0

You can use form_alter hook to do it:

/**
 * Implements hook_form_alter().
 */
function your_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'article_node_form') {
    // Alter your field here:
    // $form['field_collection'][LANGUAGE_NONE][0]['value'];
  }
}

To debug form output, you can install Devel module and use dpm() function.

/**
 * Implements hook_form_alter().
 */
function your_module_form_alter(&$form, &$form_state, $form_id) {
  dpm($form);
}
| improve this answer | |

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.