Problem/Motivation

In 3.x, a new shipping information card is added on the order view page, which allows editing shipment via a modal form, and it is not possible to add any other fields to this form except the predefined ones. The only way to do that is to override the form class.

Steps to reproduce

Add a custom field to any shipment type
Try to add this custom field to the edit modal form

Proposed resolution

Define a new hook that will allow to add more components to the form and call it in the ShipmentEditModalForm

Create a new form mode to manage fields on the edit form

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tbkot created an issue. See original summary.

tbkot’s picture

Title: Imposible to add fields in the shipping modal form » Impossible to add fields in the shipping modal form
jsacksick’s picture

The hook or overriding the form class would both require writing code... We don't really define hooks anywhere else... So not sure that is really useful? What's the problem with extending the form class?

Maybe we're just missing a protected helper that can be overridden from a child class. The main difference ofc is that wouldn't be an official API.

Also, I can't remember off the top of my head why we didn't simply use a form mode here?

tbkot’s picture

Issue summary: View changes
tbkot’s picture

Status: Active » Needs review

Now it should use a new form display if it is configured. Otherwise, the behavior of this form remains the same (only required fields are shown).