Issue with text_format in Form API

Created on 4 October 2018, about 6 years ago
Updated 13 April 2023, over 1 year ago

Basically, with the following code, the form will not submit unless the text_format's format field has a selection made by the client/user. (When tied into the #state of the checkbox).

    $form['mail_settings_fieldset'] = [
      '#type' => 'fieldset',
      '#title' => $this->t('Attendee confirmation email settings'),
    ];
    $form['mail_settings_fieldset']['signupSendMail'] = [
      '#type' => 'checkbox',
      '#title' => t('Select if you wish to send an email to the client, when a new signup is submitted'),
      '#default_value' => (isset($signupSendMail)) ? $signupSendMail : 0,
    ];
    $form['mail_settings_fieldset']['subject'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Subject'),
      '#maxlength' => 254,
      '#default_value' => (isset($subject)) ? $subject : '',
      '#states' => [
        'required' => [
          ':input[name="signupSendMail"]' => [
            'checked' => true,
          ],
        ],
      ],
    ];
    $form['mail_settings_fieldset']['message'] = [
      '#type' => 'text_format',
      '#title' => $this->t('Message'),
      '#format' => (isset($format)) ? $format : 'basic_html',
      '#allowed_formats' => [
        'basic_html',
        'restricted_html',
        'full_html',
      ],
      '#default_value' => (isset($body)) ? $body : '',
      '#description' => t('Please make sure that all urls are absolute.'),
      '#states' => [
        'required' => [
          ':input[name="signupSendMail"]' => [
            'checked' => true,
          ],
        ],
      ],
    ];
    $form['actions'] = [
      '#type' => 'actions',
    ];
    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Configure signup'),
    ];
πŸ’¬ Support request
Status

Closed: outdated

Version

9.5

Component
FormΒ  β†’

Last updated about 10 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States irodriguez

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    @irodriguez, has this been resolved? If so, add a comment saying what you because it can help others.

    I asked about this in #bugsmash because this code snippet in the issue summary is not part of core. larowlan agreed and pointed out that this is a support request. I am changing the status now.

  • Status changed to Closed: outdated over 1 year ago
Production build 0.71.5 2024