I have a site with Drupal 8 and Commerce 2. Now trying to build a custom "Create new order" -form for admin. Created a custom module and form with buildForm() function. Managed to add selection for store and user (as entity reference fields) but I got stuck when trying to add products for order. I had an idea to use inline entity form for this, but I can't figure out how to do that.

In buildForm() function I have

 $form['products']['ief'] = [
    '#type' => 'inline_entity_form',
    '#entity_type' => 'commerce_order_item',
    '#bundle' => 'default',
    '#form_mode' => 'default',
    '#op' => 'add'

This shows 3 fields (Product variation auto complete field, quantity and unit price) but it does not show "Create new order item"-button. Should this work out-of-box and is there something wrong with field settings...?

Or do I need to add submit button and some ajax callback myself to generate new fieldset?

Any help is appreciated :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.