public static function TargetingFormTrait::targetFormValidate in Doubleclick for Publishers (DFP) 8
Validation function used by an individual target in the targeting form.
File
- src/
Form/ TargetingFormTrait.php, line 133 - Contains \Drupal\dfp\Form\TargetingFormTrait.
Class
- TargetingFormTrait
- Adds a form for saving DFP targeting information.
Namespace
Drupal\dfp\FormCode
public static function targetFormValidate(array $element, FormStateInterface &$form_state) {
if (empty($element['target']['#value']) && !empty($element['value']['#value'])) {
$form_state
->setError($element['target'], t('The target cannot be empty if a value exists.'));
}
elseif (!empty($element['target']['#value']) && empty($element['value']['#value'])) {
$form_state
->setError($element['value'], t('The value cannot be empty if a target exists.'));
}
}