Commit 6061967b authored by alexpott's avatar alexpott
Browse files

Issue #1953770 by amateescu: Move the field-specific settings form elements at the top of the form.

parent 7b10d499
......@@ -98,6 +98,18 @@ public function buildForm(array $form, FormStateInterface $form_state, FieldConf
$form['field_storage']['#prefix'] = '<div class="messages messages--error">' . $this->t('There is data for this field in the database. The field settings can no longer be changed.') . '</div>' . $form['field_storage']['#prefix'];
}
// Add settings provided by the field module. The field module is
// responsible for not returning settings that cannot be changed if
// the field already has data.
$form['field_storage']['settings'] = array(
'#weight' => -10,
);
// Create an arbitrary entity object, so that we can have an instantiated
// FieldItem.
$ids = (object) array('entity_type' => $this->field->entity_type, 'bundle' => $this->field->bundle, 'entity_id' => NULL);
$entity = _field_create_entity_from_ids($ids);
$form['field_storage']['settings'] += $entity->get($field_storage->getName())->first()->storageSettingsForm($form, $form_state, $field_storage->hasData());
// Build the configurable field values.
$cardinality = $field_storage->getCardinality();
$form['field_storage']['cardinality_container'] = array(
......@@ -141,18 +153,6 @@ public function buildForm(array $form, FormStateInterface $form_state, FieldConf
$form['field_storage']['module'] = array('#type' => 'value', '#value' => $field_storage->module);
$form['field_storage']['translatable'] = array('#type' => 'value', '#value' => $field_storage->isTranslatable());
// Add settings provided by the field module. The field module is
// responsible for not returning settings that cannot be changed if
// the field already has data.
$form['field_storage']['settings'] = array(
'#weight' => 10,
);
// Create an arbitrary entity object, so that we can have an instantiated
// FieldItem.
$ids = (object) array('entity_type' => $this->field->entity_type, 'bundle' => $this->field->bundle, 'entity_id' => NULL);
$entity = _field_create_entity_from_ids($ids);
$form['field_storage']['settings'] += $entity->get($field_storage->getName())->first()->storageSettingsForm($form, $form_state, $field_storage->hasData());
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save field settings'));
return $form;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment