You are here

function bynder_form_alter in Bynder 8.3

Same name and namespace in other branches
  1. 8 bynder.module \bynder_form_alter()
  2. 8.2 bynder.module \bynder_form_alter()
  3. 4.0.x bynder.module \bynder_form_alter()

Implements hook_form_alter().

File

./bynder.module, line 60
Provides bynder integration.

Code

function bynder_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ('media_bynder_edit_form' == $form_id) {

    /** @var \Drupal\media\MediaInterface $entity */
    $entity = $form_state
      ->getBuildInfo()['callback_object']
      ->getEntity();
    if ($entity
      ->getSource() instanceof Bynder) {
      $form['edit_on_bynder'] = [
        '#type' => 'inline_template',
        '#template' => 'It is strongly advised to <a href="{{ uri }}" target="_blank"><i>edit asset\'s metadata on Bynder.</i></a> Please note that the changes won\'t be automatically updated here.',
        '#context' => [
          'uri' => get_uri_to_bynder($entity),
        ],
      ];
    }
  }
}