You are here

public function FlexiformElementField_entityreference::form in Flexiform 7

Return the form element for this FlexiformElement.

Overrides FlexiformElementField::form

File

includes/element/fields/entityreference.inc, line 15
Contains FlexiformElementField_entityreference class.

Class

FlexiformElementField_entityreference
Class for entityreference Field API elements.

Code

public function form($form, &$form_state, $entity, $language = LANGUAGE_NONE) {
  $form = parent::form($form, $form_state, $entity, $language);
  if ($this
    ->getWidgetType() == 'entityreference_autocomplete') {
    foreach (element_children($form[$this->element_namespace][$language]) as $delta) {
      $element =& $form[$this->element_namespace][$language][$delta]['target_id'];
      $this
        ->formAlterAutocompleteElement($element, $entity);
    }
  }
  else {
    if ($this
      ->getWidgetType() == 'entityreference_autocomplete_tags') {
      $this
        ->formAlterAutocompleteElement($form[$this->element_namespace][$language], $entity);
    }
  }
  return $form;
}