function tripal_get_term_lookup_form_result
3.x tripal.terms.api.inc | tripal_get_term_lookup_form_result($form, $form_state, $field_name = '', $delta = 0) |
Returns the terms selected from the tripal_get_term_lookup_form.
Parameters
$form: The form (or $widget form).
$form_state: The form state.
$field_name: The name of the field, if this form is being added to a field widget.
$delta: The delta value for the field if this form is being added to a field widget.
Return value
An array of term objects for each of the user selected terms.
Related topics
1 call to tripal_get_term_lookup_form_result()
- schema__additional_type_widget::validate in tripal_chado/
includes/ TripalFields/ schema__additional_type/ schema__additional_type_widget.inc
File
- tripal/
api/ tripal.terms.api.inc, line 718 - Provides an application programming interface (API) for working with controlled vocaublary terms.
Code
function tripal_get_term_lookup_form_result($form, $form_state, $field_name = '', $delta = 0) {
$values = array();
$selected = array();
if ($field_name) {
if (array_key_exists('term_match', $form_state['values'][$field_name]['und'][$delta])) {
$values = $form_state['values'][$field_name]['und'][$delta]['term_match']['terms_list'];
}
}
else {
$values = $form_state['values'];
}
foreach ($values as $key => $value) {
$matches = array();
if (preg_match("/^term-(\d+)$/", $key, $matches) and $values['term-' . $matches[1]]) {
$cvterm_id = $matches[1];
$selected[] = chado_generate_var('cvterm', array('cvterm_id' => $cvterm_id));
}
}
return $selected;
}