Line 104, select_or_other.module:
if ($element['#select_type'] == 'checkboxes') {
$element['select']['#process'] = array('select_or_other_expand_checkboxes');
}
This kills all process functions defined by hook_elemens() from other modules. I have this:
function multicolumncheckboxesradios_elements() {
return array(
'checkboxes' => array(
'#multicolumn' => FALSE,
'#process' => array('multicolumncheckboxesradios_element_process'),
),
}
but because of line 104, my process function is no longer called. Should remove line 104 and do something like this:
function select_or_other_elements() {
return array(
'checkboxes' => array(
'#multicolumn' => FALSE,
'#process' => array('select_or_other_expand_checkboxes'),
),
}
function select_or_other_expand_checkboxes($element) {
if ($element IS CREATED BY SELECT_OR_OTHER) {
foreach (element_children($element) as $key) {
$element[$key]['#return_value'] = check_plain($element[$key]['#return_value']);
$element[$key]['#name'] = $element['#name'] . '[' . $element[$key]['#return_value'] . ']';
$element[$key]['#value_callback'] = 'select_or_other_checkbox_value';
$element[$key]['#pre_render'][] = 'select_or_other_checkbox_prerender';
}
}
return $element;
}
Comments
Comment #1
danielb commentedWhat is #multicolumn, and why do I need to put that in? I don't see it described in http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...
And I don't understand your suggested solution... where is the original code from the implementation of hook_elements() :/
A bit confused by this - can you explain further please?
Comment #2
danielb commentedAlso if you understand this well enough is there any reason we can't just change this:
$element['select']['#process'] = array('select_or_other_expand_checkboxes');to this:
$element['select']['#process'][] = 'select_or_other_expand_checkboxes';that way it won't kill the other functions off.....
but will it work properly like this? Given that I don't understand what the other process functions will do, it's a bit worrying?
Comment #3
mattyoung commented>where is the original code from the implementation of hook_elements() :/
http://api.drupal.org/api/drupal/modules--system--system.module/function...
and I extend the "checkboxes" element with hook_elements() to make it display in columns.
>What is #multicolumn, and why do I need to put that in?
Sorry, cut and paste mistake. You don't need that.
>$element['select']['#process'] = array('select_or_other_expand_checkboxes');
>
$element['select']['#process'][] = 'select_or_other_expand_checkboxes';They both do the same and it won't work. By directly setting the #process key here, the #process functions defined by
hook_elements()are "overridden". They won't be called anymore.>Given that I don't understand what the other process functions will do, it's a bit worrying?
It doesn't matter "what the other process functions will do". What's important is modules can define/add them to do anything they want and we must not override them (unless you really really mean to but in this case, it's not).
Patch is attached (untestd).
Comment #4
danielb commentedOh right I see what you're saying, as a patch it makes perfect sense. I'll look into it soon. Thanks.
I'll need to see if there is an equivalent problem in Drupal 7.
Comment #5
danielb commentedThanks again, I've committed that.