You are here

protected static function ProfileFieldCopy::getFormDisplay in Commerce Shipping 8.2

Gets the form display for the given profile and form mode.

Parameters

\Drupal\profile\Entity\ProfileInterface $profile: The profile.

string $form_mode: The form mode.

string[] $remove_fields: The fields to remove.

Return value

\Drupal\Core\Entity\Display\EntityFormDisplayInterface The form display.

3 calls to ProfileFieldCopy::getFormDisplay()
ProfileFieldCopy::alterForm in src/ProfileFieldCopy.php
Alters the inline form.
ProfileFieldCopy::submitForm in src/ProfileFieldCopy.php
Submits the inline form.
ProfileFieldCopy::validateForm in src/ProfileFieldCopy.php
Validates the inline form.

File

src/ProfileFieldCopy.php, line 319

Class

ProfileFieldCopy
Default implementation of profile field copying ("Billing same as shipping").

Namespace

Drupal\commerce_shipping

Code

protected static function getFormDisplay(ProfileInterface $profile, $form_mode, array $remove_fields = []) {

  // @todo Investigate a static cache for form displays, since we load the
  //   billing/shipping ones twice (once in CustomerProfile, once here).
  $form_display = EntityFormDisplay::collectRenderDisplay($profile, $form_mode);
  $form_display
    ->removeComponent('revision_log_message');
  foreach ($form_display
    ->getComponents() as $name => $component) {
    if (in_array($name, $remove_fields)) {
      $form_display
        ->removeComponent($name);
    }
  }
  return $form_display;
}