You are here

function commerce_invoice_form_log_comment_form_alter in Commerce Invoice 8.2

Implements hook_form_FORM_ID_alter() for 'log_comment_form'.

File

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

Code

function commerce_invoice_form_log_comment_form_alter(array &$form, FormStateInterface $form_state) {

  // Use the invoice type label instead of the generic 'Invoice' label for the
  // activity form.
  if ($form['log_comment']['source_entity_type']['#value'] === 'commerce_invoice') {
    $invoice = Invoice::load($form['log_comment']['source_entity_id']['#value']);
    $form['log_comment']['#title'] = t('Comment on this @label', [
      '@label' => $invoice
        ->get('type')->entity
        ->label(),
    ]);
  }
}