I have a custom autocomplete field widget, defined like below:
/**
* Implements hook_field_widget_form
*/
function mymodule_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$element += array(
'#id' => 'mymodule-field',
'#type' => 'textfield',
'#default_value' => '',
'#autocomplete_path' => 'some/path',
'#element_validate' => array('mymodule_autocomplete_validate'),
);
return $element;
}
I have a content type with 2 Term reference
autocomplete fields: field foo
with standard Autocomplete term widget (tagging)
widget, and field bar
with my custom autocomplete widget.
Field bar
has a higher weight than field foo
on a node form.
mymodule
has weight 20
in system
table. taxonomy
module has weight 0
.
However, when I submit a node form which includes both fields, mymodule_autocomplete_validate()
is invoked earlier than taxonomy_autocomplete_validate()
, so $form_state['values']['field-myfield-a']
is not processed yet.
The problem is I need to use the processed value of foo
in mymodule_autocomplete_validate()
.
I have another 2 fields with same widgets but another names, and they are processed in the right order.
So the question is: how the order of execution of these functions is defined? Is there a way to change it?