function webform_icheck_webform_element_configuration_form_alter in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_icheck/webform_icheck.module \webform_icheck_webform_element_configuration_form_alter()
Implements hook_webform_element_configuration_form_alter().
File
- modules/
webform_icheck/ webform_icheck.module, line 42 - Provides support for highly customizable checkboxes and radio buttons.
Code
function webform_icheck_webform_element_configuration_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\webform_ui\Form\WebformUiElementEditForm $form_object */
$form_object = $form_state
->getFormObject();
$element_plugin = $form_object
->getWebformElementPlugin();
$element_type = $element_plugin
->getTypeName();
if (!_webform_icheck_is_supported($element_type)) {
return;
}
/** @var \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager */
$third_party_settings_manager = \Drupal::service('webform.third_party_settings_manager');
$default_icheck = $third_party_settings_manager
->getThirdPartySetting('webform_icheck', 'default_icheck');
$form['form']['icheck'] = [
'#type' => 'select',
'#title' => t('Enhance using iCheck'),
'#description' => t('Replaces @type element with jQuery <a href=":href">iCheck</a> boxes.', [
'@type' => mb_strtolower($element_plugin
->getPluginLabel()),
':href' => 'http://icheck.fronteed.com/',
]),
'#empty_option' => t('- Default -'),
'#options' => _webform_icheck_get_options(),
];
if ($default_icheck) {
$icheck_options = OptGroup::flattenOptions($form['form']['icheck']['#options']);
$form['form']['icheck']['#description'] .= '<br /><br />' . t("Leave blank to use the default iCheck style. Select 'None' to display the default HTML element.");
$form['form']['icheck']['#description'] .= '<br /><br />' . t('Defaults to: %value', [
'%value' => $icheck_options[$default_icheck],
]);
$form['form']['icheck']['#options']['none'] = t('None');
}
}