You are here

public function OptionsButtons::getFieldName in Conditional Fields 8

Same name and namespace in other branches
  1. 4.x src/Plugin/conditional_fields/handler/OptionsButtons.php \Drupal\conditional_fields\Plugin\conditional_fields\handler\OptionsButtons::getFieldName()

Get field name.

Parameters

array $field: The field object

Return value

string|false The field name

1 call to OptionsButtons::getFieldName()
OptionsButtons::checkBoxesHandler in src/Plugin/conditional_fields/handler/OptionsButtons.php
Return state for check boxes.

File

src/Plugin/conditional_fields/handler/OptionsButtons.php, line 197

Class

OptionsButtons
Provides states handler for Check boxes/radio buttons.

Namespace

Drupal\conditional_fields\Plugin\conditional_fields\handler

Code

public function getFieldName(array $field) {
  $field_name = false;
  if (isset($field['#name'])) {
    $field_name = $field['#name'];
  }
  elseif (isset($field['#field_name'])) {
    $field_name = $field['#field_name'];
  }
  elseif (isset($field['#array_parents']) && !empty($field['#array_parents'])) {
    $field_name = $field['#parents'][0];
  }
  elseif (isset($field['#parents']) && is_array($field['#parents'])) {
    $field_name = $field['#parents'][0];
  }
  return $field_name;
}