You are here

public function CustomStylesDeleteForm::buildForm in BeautyTips 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfirmFormBase::buildForm

File

beautytips_manager/src/Form/CustomStylesDeleteForm.php, line 39

Class

CustomStylesDeleteForm

Namespace

Drupal\beautytips_manager\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $id = NULL) {
  $this->style = beautytips_manager_get_custom_style($id);
  if (empty($this->style)) {
    throw new NotFoundHttpException();
  }
  if ($this->style->name == \Drupal::config('beautytips.basic')
    ->get('beautytips_default_style')) {
    return [
      'warning' => [
        '#type' => 'markup',
        '#markup' => t('You cannot delete this style because is set as the default style. You may change this !link.', [
          '!link' => Link::createFromRoute(t('here'), 'beautytips.config')
            ->toString(),
        ]),
      ],
    ];
  }
  else {
    return parent::buildForm($form, $form_state);
  }
}