You are here

public function Conditions::conditionalFieldsConditions in Conditional Fields 8

Same name and namespace in other branches
  1. 4.x src/Conditions.php \Drupal\conditional_fields\Conditions::conditionalFieldsConditions()

List of states of a control field that may be used to evaluate a condition.

File

src/Conditions.php, line 181

Class

Conditions
Provide conditional field's lists.

Namespace

Drupal\conditional_fields

Code

public function conditionalFieldsConditions($checkboxes = TRUE) {

  // Supported by States API.
  $conditions = [
    '!empty' => $this
      ->t('Filled'),
    'empty' => $this
      ->t('Empty'),
    'touched' => $this
      ->t('Touched'),
    '!touched' => $this
      ->t('Untouched'),
    'focused' => $this
      ->t('Focused'),
    '!focused' => $this
      ->t('Unfocused'),
  ];
  if ($checkboxes) {

    // Relevant only if control is a list of checkboxes.
    $conditions['checked'] = $this
      ->t('Checked');
    $conditions['!checked'] = $this
      ->t('Unchecked');
  }
  $conditions['value'] = $this
    ->t('Value');

  // Allow other modules to modify the conditions.
  $this->moduleHandler
    ->alter('conditionalFieldsConditions', $conditions);
  return $conditions;
}