Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi there,
Nice mod. I'm integrating the FormAPI element_info type stuff. Pretty neat.
I think I found a bit of a bug though in 'select_or_other.module' line 199:
Existing...
<?php
// Also add in a custom class for each.
if (isset($element[$sub_element]['#attributes']['class'])) {
$element[$sub_element]['#attributes'] .= array('class' => array('select-or-other-' . $sub_element));
}
else {
$element[$sub_element]['#attributes'] = array('class' => array('select-or-other-' . $sub_element));
}
?>
Should be...
<?php
// Also add in a custom class for each.
if (isset($element[$sub_element]['#attributes']['class'])) {
$element[$sub_element]['#attributes']['class'][] = 'select-or-other-' . $sub_element;
}
else {
$element[$sub_element]['#attributes'] = array('class' => array('select-or-other-' . $sub_element));
}
?>
If I try to add attributes to the 'select' or 'other' form element I use the '#select_attributes' or '#other_attributes'. When this is specified the first conditions executes and you perform a string concat on arrays. I expect you meant to use += instead of .= .
Like the module and hope this helps.
John
Comments
Comment #1
danielb CreditAttribution: danielb commentedooh yeah that's all wrong, it can be simplified a bit too I think
Comment #2
jonlhouse CreditAttribution: jonlhouse commentedNo worries.
If you are taking potential feature requests I have an idea:
Make an option to start with the "Other" field visible to start with. Right now you append "Other:" (or user-supplied label to the end of the options). Maybe you could optionally prepend "Other:" and make the textfield by default (e.g. "#other_default => TRUE|FALSE").
Right now I'm using the widget for a combo-box where I'm having the user input a numeric value. For mobile devices I'm using the select part as a short-cut to some pre-set numbers. Having an option to show the "other" textfield by default would eliminate the extra step of opening the drop-down, selecting "Other:" than entering a value in.
I totally understand your default ux since for things like taxonomy your way make more sense.
On a side note, I doubt most users are using this as developers in custom forms but you could improve your documentation about the Form API properties. I had to big through source to find #other_unknown_defaults and #other_deliminater as well as that #select_
and #other_
go to their respective form elements. However, I like the way you did that, I works great for me!
Thanks for the hard work,
Comment #3
danielb CreditAttribution: danielb commentednot even gonna read that mate
Comment #4
danielb CreditAttribution: danielb commentedfixed in the repository, and will appear in the next development snapshot (check the date).