When I add a field with "Commerce adjustment" field type, click save, then I was redirected to the field setting page, below are the errors:

Notice: Undefined index: default_formatter in Drupal\Core\Field\FormatterPluginManager->prepareConfiguration() (line 150 of core/lib/Drupal/Core/Field/FormatterPluginManager.php).
Drupal\Core\Field\FormatterPluginManager->prepareConfiguration(Array, Array) (Line: 331)
Drupal\Core\Entity\EntityDisplayBase->setComponent('field_delivery_fee', Array) (Line: 456)
Drupal\field_ui\Form\FieldStorageAddForm->configureEntityViewDisplay('field_delivery_fee', NULL) (Line: 363)
Drupal\field_ui\Form\FieldStorageAddForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('field_ui_field_storage_add_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('field_ui_field_storage_add_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I am not sure if this is related, the order adjustments out of box are not visible via REST.

Comments

skyredwang created an issue. See original summary.

bojanz’s picture

There is no REST integration for adjustments, so that part is expected.

Do note that you're not supposed to create an adjustments field for a delivery fee, you're supposed to use the existing one.

mglaman’s picture

 *   list_class = "\Drupal\commerce_order\Plugin\Field\FieldType\AdjustmentItemList",
 *   default_widget = "commerce_adjustment_default",

https://github.com/drupalcommerce/commerce/blob/8.x-2.x/modules/order/sr...

Because we do not provide a formatter. I guess it needs to be set to "hidden" or something to avoid this error? Never added this field type via the UI. It should probably has "no_ui = TRUE" like the PasswordItem field. With "no_ui" set we can mitigate this whole problem, forcing it to be added via base field definitions, etc.

See PasswordItem http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Field/Plugin...

 *   no_ui = TRUE,
bojanz’s picture

Yes, let's add no_ui.

bojanz’s picture

Title: Adding an adjustment field error » The adjustments field type should not be available from the UI

  • bojanz committed 2c0d6f5 on 8.x-2.x
    Issue #2840535 by bojanz, mglaman: The adjustments field type should not...
bojanz’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.