Skip to content

Commit

Permalink
Merge pull request #1259 from tripal/1258-tv3-tripal_get_term_lookup_…
Browse files Browse the repository at this point in the history
…form

Issue #1258 add radio button option
  • Loading branch information
spficklin committed Mar 19, 2022
2 parents d3123a7 + f7e0faa commit 731f76e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
18 changes: 13 additions & 5 deletions tripal/api/tripal.terms.api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,19 @@ function tripal_get_vocabularies() {
* Indicates if this form element is required.
* @param $field_name
* The name of the field, if this form is being added to a field widget.
* @param $delta
* @param $delta
* The delta value for the field if this form is being added to a field
* widget.
* @param $callback
* Ajax callback function, defaults to
* 'tripal_get_term_lookup_form_ajax_callback'.
* @param $wrapper
* Ajax wrapper ID.
* @param $validate
* Widget validation configuration.
* @param $weight
* The weight value for the field if this form is being added to a field
* widget.
*
* @ingroup tripal_terms_api
*/
Expand Down Expand Up @@ -681,9 +691,6 @@ function tripal_get_term_lookup_form(&$form, &$form_state, $default_name = '',
// TODO: this should not call the chado functions because we're in the
// tripal module.
$terms = chado_generate_var('cvterm', $match, ['return_array' => TRUE]);
if ($terms) {
$terms = chado_expand_var($terms, 'field', 'cvterm.definition');
}
$num_terms = 0;
$selected_term = '';

Expand All @@ -699,9 +706,10 @@ function tripal_get_term_lookup_form(&$form, &$form_state, $default_name = '',
$attrs = ['checked' => 'checked'];
}
$term_element_name = 'term-' . $term->cvterm_id . '-' . $delta;
$term = chado_expand_var($term, 'field', 'cv.definition');
$definition = property_exists($term, 'definition') ? $term->definition : '';
$form['term_match' . $delta]['terms_list' . $delta][$term_element_name] = [
'#type' => 'checkbox',
'#type' => 'radio',
'#title' => $term->name,
'#default_value' => $checked,
'#attributes' => $attrs,
Expand Down
4 changes: 2 additions & 2 deletions tripal/includes/tripal.fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ function tripal_field_instance_settings_form_alter_process($element, &$form_stat
$element['field_term']['instructions'] = [
'#type' => 'item',
'#title' => 'Matching terms',
'#markup' => t('Please select the term the best matches the
'#markup' => t('Please select the term that best matches the
content type you want to associate with this field. If the same term exists in
multiple vocabularies you will see more than one option below.'),
];
Expand All @@ -650,7 +650,7 @@ function tripal_field_instance_settings_form_alter_process($element, &$form_stat
$attrs = ['checked' => 'checked'];
}
$element['field_term']['term-' . $term->cvterm_id] = [
'#type' => 'checkbox',
'#type' => 'radio',
'#title' => $term->name,
'#default_value' => $default,
'#attributes' => $attrs,
Expand Down
4 changes: 2 additions & 2 deletions tripal_chado/includes/tripal_chado.semweb.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,7 @@ function tripal_chado_semweb_edit_form($form, &$form_state, $table = NULL, $colu
$form['terms_list'] = [
'#type' => 'fieldset',
'#title' => t('Matching Terms'),
'#description' => t('Please select the term the best matches the
'#description' => t('Please select the term that best matches the
content type you want to create. If the same term exists in
multiple vocabularies you will see more than one option below.'),
];
Expand All @@ -2352,7 +2352,7 @@ function tripal_chado_semweb_edit_form($form, &$form_state, $table = NULL, $colu
$attrs = ['checked' => 'checked'];
}
$form['terms_list']['term-' . $term->cvterm_id] = [
'#type' => 'checkbox',
'#type' => 'radio',
'#title' => $term->name,
'#default_value' => $default,
'#attributes' => $attrs,
Expand Down

0 comments on commit 731f76e

Please sign in to comment.