Untitled

mail@pastecode.io avatarunknown
plain_text
2 months ago
882 B
1
Indexable
Never
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Implements the custom form.
 */
class CustomForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'custom_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    for ($i = 1; $i <= 100; $i++) {
      $form['text_area_field_' . $i] = [
        '#type' => 'text_format',
        '#title' => $this->t('Text Area Field @num', ['@num' => $i]),
        '#format' => 'full_html',
        '#default_value' => '',
      ];
    }

    $form['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Submit'),
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Process form submission here.
  }
}