Add the subscription form below the body content

Add the subscription form below the body content for daily email nodes.
This commit is contained in:
Oliver Davies 2025-07-07 22:22:37 +01:00
parent a0f25bb985
commit 6b15e5c40a
3 changed files with 61 additions and 1 deletions

View file

@ -20,6 +20,19 @@ final class KitSubscriptionForm extends FormBase {
* @return array<non-empty-string, mixed>
*/
public function buildForm(array $form, FormStateInterface $formState): array {
// TODO: refactor to a custom theme function.
// TODO: make this optional. I may not want the intro text on every form - especially when two are on the same page.
$form['intro'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'class' => 'prose prose-p:text-black prose-a:font-light prose-a:text-blue-primary prose-p:text-lg prose-blockquote:border-blue-primary dark:marker:text-white prose-li:my-1 prose-li:text-lg prose-figcaption:text-white prose-li:text-black marker:text-black dark:prose-p:text-white dark:prose-invert dark:prose-a:text-blue-400 dark:prose-blockquote:border-blue-400 dark:prose-li:text-white prose-a:hover:no-underline prose-h2:text-xl prose-code:font-normal prose-h2:mb-4 prose-ul:my-3 dark:prose-hr:border-neutral-400 prose-code:before:content-[\'\'] prose-code:after:content-[\'\'] prose-pre:bg-neutral-200 prose-pre:text-black prose-pre:rounded-none prose-code:bg-neutral-200',
'style' => 'margin-bottom: 1rem;',
],
];
$form['intro']['text']['#markup'] = '<p>' . t('Subscribe to my daily newsletter for software professionals on software development and delivery, Drupal, DevOps, community, and open-source.') . '</p>';
$form['email_address'] = [
'#placeholder' => 'me@example.com',
'#title' => $this->t('What is your best email address?'),