function honeypot_form_yamlform_third_party_settings_form_alter in YAML Form 8
Implements hook_form_FORM_ID_alter().
File
- third_party_settings/
yamlform.honeypot.inc, line 154 - Integrates third party settings on the Honeypot module's behalf.
Code
function honeypot_form_yamlform_third_party_settings_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\yamlform\YamlFormThirdPartySettingsManagerInterface $third_party_settings_manager */
$third_party_settings_manager = \Drupal::service('yamlform.third_party_settings_manager');
/** @var \Drupal\yamlform\YamlFormInterface $yamlform */
$yamlform = $form_state
->getFormObject()
->getEntity();
$honeypot = $yamlform
->getThirdPartySetting('honeypot', 'honeypot');
if (\Drupal::config('honeypot.settings')
->get('protect_all_forms')) {
$honeypot_state = YAMLFORM_HONEYPOT_ENABLED_ALL;
}
elseif ($third_party_settings_manager
->getThirdPartySetting('honeypot', 'honeypot')) {
$honeypot_state = YAMLFORM_HONEYPOT_ENABLED_YAMLFORM;
}
else {
$honeypot_state = YAMLFORM_HONEYPOT_NEUTRAL;
}
$time_restriction = $yamlform
->getThirdPartySetting('honeypot', 'time_restriction');
if (\Drupal::config('honeypot.settings')
->get('time_limit') == 0) {
$time_restriction_state = YAMLFORM_HONEYPOT_DISABLED_ALL;
}
elseif ($third_party_settings_manager
->getThirdPartySetting('honeypot', 'time_restriction')) {
$time_restriction_state = YAMLFORM_HONEYPOT_ENABLED_YAMLFORM;
}
else {
$time_restriction_state = YAMLFORM_HONEYPOT_NEUTRAL;
}
_yamlform_honeypot_form($form, $form_state, $honeypot, $honeypot_state, $time_restriction, $time_restriction_state, t('@label form', [
'@label' => $yamlform
->label(),
]));
}