You are here

function commerce_invoice_form_state_machine_transition_form_alter in Commerce Invoice 8.2

Implements hook_form_BASE_FORM_ID_alter() for 'state_machine_transition_form'.

File

./commerce_invoice.module, line 159
Defines the Invoice entity and associated features.

Code

function commerce_invoice_form_state_machine_transition_form_alter(array &$form, FormStateInterface $form_state) {
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  if ($entity instanceof InvoiceInterface) {
    foreach (Element::children($form['actions']) as $action) {

      // Append the invoice type label to the transition label.
      $form['actions'][$action]['#value'] = t('@transition_label @invoice_bundle', [
        '@transition_label' => $form['actions'][$action]['#value'],
        // @todo Stop using mb_strtolower() when
        //   https://www.drupal.org/project/drupal/issues/2765065 is fixed.
        '@invoice_bundle' => mb_strtolower($entity
          ->get('type')->entity
          ->label()),
      ]);
    }
  }
}