Drupal 模組開發 - 改寫 field_collection 表單

以下 從field_wiget_form著手

function my_module_field_widget_form_alter(&$element, &$form_state, $context) {
  if ("field_my_field_collection" == $element['#bundle']) {
    if ("field_my_field_collection" == $element['#field_name']) {
      $element['#access'] = FALSE;
    }
  }
// dpm(array($element, $form_state, $context), "field_name: " . $element['#field_name'] );
}

以下則從主要表單針對每一個item表單改寫

function mymodule_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'myformid') {
$delta = 0;
$max_delta = $form['field_my_field_collection'][LANGUAGE_NONE]['#max_delta'];
while ($delta <= $max_delta) {
$form['field_my_field_collection'][LANGUAGE_NONE][$delta]['field_myfield']   
[LANGUAGE_NONE][0]['#access'] = FALSE;
  $delta++;
    }
  }
}