<?php $this->extend('block_unsearchable'); ?>

<?php $this->block('content'); ?>

  <form<?php if ($this->action): ?> action="<?= $this->action ?>"<?php endif; ?> id="<?= $this->formId ?>" method="post">
    <div class="formbody input-group w-100">
      <input type="hidden" name="FORM_SUBMIT" value="<?= $this->formId ?>">
      <input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}">

      <?php if ($this->message): ?>
        <p class="w-100 alert alert-warning alert-dismissible fade show my-2 <?= $this->mclass ?>"><?= $this->message ?></p>
      <?php endif; ?>

      <?php if (!$this->showChannels): ?>
        <?php foreach ($this->channels as $id=>$title): ?>
          <input type="hidden" name="channels[]" value="<?= $id ?>">
        <?php endforeach; ?>
      <?php endif; ?>

        <label for="ctrl_email_<?= $this->id ?>" class="invisible"><?= $this->emailLabel ?></label>
        <input type="text" name="email" id="ctrl_email_<?= $this->id ?>" class="form-control text mandatory" value="<?= $this->email ?>" placeholder="<?= $this->emailLabel ?>" required>

      <?php if ($this->showChannels): ?>
        <div class="widget widget-checkbox">
          <fieldset id="ctrl_channels_<?= $this->id ?>" class="checkbox_container">
            <legend class="invisible"><?= $this->channelsLabel ?></legend>
              <?php foreach ($this->channels as $id=>$title): ?>
              <span><input type="checkbox" name="channels[]" id="opt_<?= $this->id ?>_<?= $id ?>" value="<?= $id ?>" class="checkbox"<?php if (is_array($this->selectedChannels) && in_array($id, $this->selectedChannels)) echo ' checked'; ?>> <label for="opt_<?= $this->id ?>_<?= $id ?>"><?= $title ?></label></span>
            <?php endforeach; ?>
            </fieldset>
        </div>
      <?php endif; ?>

      <?= $this->captcha ?>

      <div class="w-25 input-group-append widget widget-submit">
        <button type="submit" class="w-100 btn btn-success"><?= $this->submit ?></button>
      </div>
    </div>
  </form>

<?php $this->endblock(); ?>
