protected function FlexiformElementField_entityreference::formAlterAutocompleteElement in Flexiform 7
Alter the selection element.
1 call to FlexiformElementField_entityreference::formAlterAutocompleteElement()
- FlexiformElementField_entityreference::form in includes/
element/ fields/ entityreference.inc - Return the form element for this FlexiformElement.
File
- includes/
element/ fields/ entityreference.inc, line 34 - Contains FlexiformElementField_entityreference class.
Class
- FlexiformElementField_entityreference
- Class for entityreference Field API elements.
Code
protected function formAlterAutocompleteElement(&$element, $entity) {
$ac_path = $this
->getWidgetType() == 'entityreference_autocomplete' ? 'flexiform/entityreference/autocomplete/single' : 'flexiform/entityreference/autocomplete/tags';
$element['#autocomplete_path'] = $ac_path . '/' . $this->flexiform->form . '/' . $this->element_namespace;
if ($entity_id = entity_id($this->entity_type, $entity)) {
$element['#autocomplete_path'] .= "/{$entity_id}";
}
else {
$element['#autocomplete_path'] .= "/NULL";
}
foreach ($element['#element_validate'] as &$callback) {
if ($callback == '_entityreference_autocomplete_validate') {
$callback = array(
$this,
'autocompleteValidate',
);
}
if ($callback == '_entityreference_autocomplete_tags_validate') {
$callback = array(
$this,
'autocompleteTagsValidate',
);
}
}
}