public function HideIfString::alterForm in Field Formatter Condition 8
Alter the condition form.
Parameters
array $form: Condition formular.
array $settings: Settings array.
Overrides FieldFormatterConditionBase::alterForm
File
- src/
Plugin/ Field/ FieldFormatter/ Condition/ HideIfString.php, line 23
Class
- HideIfString
- The plugin for check empty fields.
Namespace
Drupal\fico\Plugin\Field\FieldFormatter\ConditionCode
public function alterForm(&$form, $settings) {
$options = [];
$fields = $this
->getEntityFields($settings['entity_type'], $settings['bundle']);
$allowed_field_types = fico_text_types();
foreach ($fields as $field_name => $field) {
if ($field_name != $settings['field_name'] && in_array($field
->getType(), $allowed_field_types)) {
$options[$field_name] = $field
->getLabel();
}
}
$default_target = isset($settings['settings']['target_field']) ? $settings['settings']['target_field'] : NULL;
$default_string = isset($settings['settings']['string']) ? $settings['settings']['string'] : NULL;
$form['target_field'] = [
'#type' => 'select',
'#title' => t('Select target field'),
'#options' => $options,
'#default_value' => $default_target,
];
$form['string'] = array(
'#type' => 'textfield',
'#title' => t('Enter target string'),
'#default_value' => $default_string,
);
}