public function NodeField::fieldsCallback in Entity Field Condition 8
Handles switching the available fields.
Handles switching the available fields based on the selected content type (node type).
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 Returns the available fields for the selected content type.
File
- src/
Plugin/ Condition/ NodeField.php, line 220
Class
- NodeField
- Provides a 'Node Field' condition.
Namespace
Drupal\entity_field_condition\Plugin\ConditionCode
public function fieldsCallback(array $form, FormStateInterface $form_state) {
// Getting the node type.
$node_type = $form_state
->getValues()['visibility']['node_field']['entity_bundle'];
// Adding the content type fields.
$form['visibility']['node_field']['field']['#options'] = $this
->getNodeFields($node_type);
return $form['visibility']['node_field']['field'];
}