function persian_date_form_alter in Persian Date for Drupal 8 8.4
Implements hook_form_alter().
File
- ./
persian_date.module, line 161 - Contains persian_date.module.
Code
function persian_date_form_alter(&$form, $form_state, $form_id) {
if (!PersianLanguageDiscovery::isPersian()) {
return;
}
// integration with better_exposed_filters
global $persian_date_widgets;
if (isset($persian_date_widgets)) {
if (isset($form['#attached']) && isset($form['#attached']['library']) && is_array($form['#attached']['library']) && in_array('better_exposed_filters/general', $form['#attached']['library'])) {
foreach ($persian_date_widgets as $field_id) {
$form[$field_id]['#attributes']['type'] = 'date';
$form[$field_id]['#attributes']['class'][] = 'persian-datepicker';
$form[$field_id]['value']['#attributes']['type'] = 'date';
$form[$field_id]['value']['#attributes']['class'][] = 'persian-datepicker';
$form[$field_id]['min']['#attributes']['class'][] = 'persian-datepicker';
$form[$field_id]['max']['#attributes']['class'][] = 'persian-datepicker';
}
$form['#attached']['library'][] = 'persian_date/core';
}
}
}