Skip to content
Snippets Groups Projects

Issue #2700667 : Notice: Undefined index: #type in Drupal\Core\Form\FormHelper::processStates()

Open Issue #2700667 : Notice: Undefined index: #type in Drupal\Core\Form\FormHelper::processStates()
2 files
+ 39
1
Compare changes
  • Side-by-side
  • Inline

Files

@@ -196,6 +196,11 @@ protected static function processStatesArray(array &$conditions, $search, $repla
* ],
* @endcode
*
* Drupal form elements are not required to support states. For states to
* work, the element has to print #attributes. Item elements work using
* #wrapper_attributes instead. States are not supported by render arrays
* where #type is markup.
*
* @param array $elements
* A render array element having a #states property as described above.
*
@@ -208,7 +213,7 @@ public static function processStates(array &$elements) {
// still want to be able to show/hide them. Since there's no actual HTML
// input element available, setting #attributes does not make sense, but a
// wrapper is available, so setting #wrapper_attributes makes it work.
$key = ($elements['#type'] == 'item') ? '#wrapper_attributes' : '#attributes';
$key = isset($elements['#type']) && $elements['#type'] === 'item' ? '#wrapper_attributes' : '#attributes';
$elements[$key]['data-drupal-states'] = Json::encode($elements['#states']);
}
Loading