I'm writing a module to change input HTML attributes with the next code:
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_alter().
*/
function custom_numeric_filter_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$field = 'yourfieldname';
if ($form_id == 'views_exposed_form' && array_key_exists($field, $form)) {
$form[$field]['#type'] = "range";
$form[$field]['#step'] = 5;
$form[$field]['#size'] = 5;
$form[$field]['#min'] = 10;
$form[$field]['#max'] = 60;
}
}
The problem is that the type gets overwritten back to number
by something else.
I have Better Exposed Filters installed, maybe it gets rewritten there but why? And how can I make sure my module code has priority? With the help from NoSssweat I made sure it was executed after BEF and it didn't help.
How can I make sure my module code has priority?
By giving your module higher weight so your hook executes last. You can achieve that like this or with thisrange
being an unknown value for some reason.BETWEEN
, just a guess.