You are here

public function SplashifyGroupEntityForm::buildForm in Splashify 8.2

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 EntityForm::buildForm

File

src/Form/SplashifyGroupEntityForm.php, line 18

Class

SplashifyGroupEntityForm
Form controller for Splashify group entity edit forms.

Namespace

Drupal\splashify\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  /* @var $entity \Drupal\splashify\Entity\SplashifyGroupEntity */
  $entity = $this->entity;
  $form = parent::buildForm($form, $form_state);

  // Use drupal states.
  $form['field_list_pages']['widget'][0]['value']['#states'] = array(
    'visible' => array(
      ':input[name="field_where"]' => array(
        'value' => 'list',
      ),
    ),
    'required' => array(
      ':input[name="field_where"]' => array(
        'value' => 'list',
      ),
    ),
  );
  $form['field_roles']['#states'] = array(
    'visible' => array(
      ':input[name="field_restrict[value]"]' => array(
        'checked' => TRUE,
      ),
    ),
  );
  $form['field_splash_mode']['#states'] = array(
    'invisible' => array(
      ':input[name="field_mode"]' => array(
        'value' => 'full_screen',
      ),
    ),
  );
  $form['field_size']['widget'][0]['value']['#states'] = array(
    'visible' => array(
      ':input[name="field_mode"]' => array(
        array(
          'value' => 'window',
        ),
        array(
          'value' => 'lightbox',
        ),
      ),
    ),
    'required' => array(
      ':input[name="field_mode"]' => array(
        array(
          'value' => 'window',
        ),
        array(
          'value' => 'lightbox',
        ),
      ),
    ),
  );
  return $form;
}