Pre-populate the next podcast episode number
This commit is contained in:
parent
7a4c0223f9
commit
6b54631f46
5 changed files with 72 additions and 1 deletions
|
@ -2,12 +2,26 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\opd_podcast\Action\GetNextPodcastEpisodeNumber;
|
||||
use Drupal\opd_podcast\Episode;
|
||||
use Drupal\opd_podcast\Guest;
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*
|
||||
* @param array{} $form
|
||||
*/
|
||||
function opd_podcast_form_node_podcast_episode_form_alter(array &$form, FormStateInterface $formState): void {
|
||||
$nextEpisodeNumber = \Drupal::service(GetNextPodcastEpisodeNumber::class);
|
||||
assert($nextEpisodeNumber instanceof GetNextPodcastEpisodeNumber);
|
||||
|
||||
$form['field_episode_number']['widget'][0]['value']['#default_value'] = $nextEpisodeNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_bundle_info_alter().
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue