diff -u b/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php --- b/core/modules/edit/lib/Drupal/edit/EditController.php +++ b/core/modules/edit/lib/Drupal/edit/EditController.php @@ -17,6 +17,7 @@ use Drupal\edit\Ajax\FieldFormSavedCommand; use Drupal\edit\Ajax\FieldFormValidationErrorsCommand; use Drupal\edit\Ajax\MetadataCommand; +use Drupal\field\FieldInstanceInterface; /** * Returns responses for Edit module routes. @@ -126,7 +127,14 @@ $entity = entity_load($form_state['entity']->entityType(), $form_state['entity']->id(), TRUE); // @todo Remove when http://drupal.org/node/1346214 is complete. $entity = $entity->getBCEntity(); - $output = field_view_field($entity, $field_name, $view_mode_id, $langcode); + + $field = $entity->getNGEntity()->get($field_name); + if ($field->getFieldDefinition() instanceof FieldInstanceInterface) { + $output = field_view_field($entity, $field_name, $view_mode_id, $langcode); + } + else { + $output = \Drupal::service('plugin.manager.field.formatter')->viewBaseField($field); + } $response->addCommand(new FieldFormSavedCommand(drupal_render($output))); } --- a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php +++ b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php @@ -8,6 +8,7 @@ namespace Drupal\edit\Form; use Drupal\Core\Entity\EntityInterface; +use Drupal\field\FieldInstanceInterface; /** * Builds and process a form for editing a single entity field. @@ -23,7 +24,13 @@ public function build(array $form, array &$form_state, EntityInterface $entity, } // Add the field form. - field_attach_form($form_state['entity'], $form, $form_state, $form_state['langcode'], array('field_name' => $form_state['field_name'])); + $field = $entity->getNGEntity()->get($field_name); + if ($field->getFieldDefinition() instanceof FieldInstanceInterface) { + field_attach_form($form_state['entity'], $form, $form_state, $form_state['langcode'], array('field_name' => $form_state['field_name'])); + } + else { + $form[$field_name] = \Drupal::service('plugin.manager.field.widget')->baseFieldForm($field, $form, $form_state, $form_state['langcode']); + } // Add a submit button. Give it a class for easy JavaScript targeting. $form['actions'] = array('#type' => 'actions'); @@ -80,7 +87,14 @@ protected function init(array &$form_state, EntityInterface $entity, $field_name */ public function validate(array $form, array &$form_state) { $entity = $this->buildEntity($form, $form_state); - field_attach_form_validate($entity, $form, $form_state, array('field_name' => $form_state['field_name'])); + $field_name = $form_state['field_name']; + $field = $entity->getNGEntity()->get($field_name); + if ($field->getFieldDefinition() instanceof FieldInstanceInterface) { + field_attach_form_validate($entity, $form, $form_state, array('field_name' => $field_name)); + } + else { + // @todo + } } /** @@ -100,13 +114,19 @@ public function submit(array $form, array &$form_state) { protected function buildEntity(array $form, array &$form_state) { $entity = clone $form_state['entity']; - field_attach_extract_form_values($entity, $form, $form_state, array('field_name' => $form_state['field_name'])); + $field_name = $form_state['field_name']; + $field = $entity->getNGEntity()->get($field_name); + if ($field->getFieldDefinition() instanceof FieldInstanceInterface) { + field_attach_extract_form_values($entity, $form, $form_state, array('field_name' => $field_name)); + } + else { + \Drupal::service('plugin.manager.field.widget')->baseFieldExtractFormValues($field, $form, $form_state, $form_state['langcode']); + } // @todo Refine automated log messages and abstract them to all entity // types: http://drupal.org/node/1678002. if ($entity->entityType() == 'node' && $entity->isNewRevision() && !isset($entity->log)) { - $instance = field_info_instance($entity->entityType(), $form_state['field_name'], $entity->bundle()); - $entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $instance['label'])); + $entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $field->getFieldDefinition()->getFieldLabel())); } return $entity;