Form constructor.
array $form: An associative array containing the structure of the form.
array $form_state: An associative array containing the current state of the form.
array The form structure.
Overrides FieldInstanceFormBase::buildForm
public function buildForm(array $form, array &$form_state, FieldInstanceInterface $field_instance = NULL) {
parent::buildForm($form, $form_state, $field_instance);
drupal_set_title($this->instance['label']);
$bundle = $this->instance['bundle'];
$entity_type = $this->instance['entity_type'];
$field_name = $this->instance['field_name'];
$entity_form_display = entity_get_form_display($entity_type, $bundle, 'default');
$field = $this->instance
->getField();
$bundles = entity_get_bundles();
$bundle_label = $bundles[$entity_type][$bundle]['label'];
$form = array(
'#bundle' => $bundle,
'#entity_type' => $entity_type,
'#field_name' => $field_name,
'#instance' => $this->instance,
);
$form['widget_type'] = array(
'#type' => 'select',
'#title' => t('Widget type'),
'#required' => TRUE,
'#options' => $this->widgetManager
->getOptions($field['type']),
'#default_value' => $entity_form_display
->getWidget($field_name)
->getPluginId(),
'#description' => t('The type of form element you would like to present to the user when creating this field in the %type type.', array(
'%type' => $bundle_label,
)),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Continue'),
);
return $form;
}