Drupal 7.x

Allows the Form API to create taxonomy autocomplete textfields for vocabularies with no term reference fields set up.

http://drupal.org/sandbox/TomCLopez/1878728

Comments

klausi’s picture

Status: Active » Needs work

Welcome,

please get a review bonus first. Then try to fix issues raised by automated review tools: http://ventral.org/pareview/httpgitdrupalorgsandboxtomclopez1878728git

t-lo’s picture

Status: Needs work » Needs review

Thanks,

The issues have been fixed in latest commit, I'll work on getting that review bonus tomorrow.

t-lo’s picture

Status: Needs review » Needs work

Still some issues remaining after re running the test

ahlofan’s picture

Code review has been done very previous reviews. Guess I don't have mention that.
It is a nice handy module! Good job! Tested the field. It worked successfully.

function custom_menu() {
  $items['custom'] = array(
    'title' => 'Test',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('custom_form'),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function custom_form($form, &$form_state) {
  $vocab = taxonomy_vocabulary_machine_name_load('tags');

  $form['test'] = array(
    '#title' => t('Textfield Title'),
    '#type' => 'textfield',
    '#autocomplete_path' => 'taxonomy_vid/autocomplete/' . $vocab->vid,
    '#element_validate' => array('taxonomy_autocomplete_validate'),
  );
/*
  $form['test'] = array(
    '#title' => t('Textfield Title'),
    '#type' => 'textfield',
  );
*/
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}

function custom_form_submit($form_id, &$form_state) {
  drupal_set_message($form_state['values']['test']);
}

Just did a quick test. I could search the taxonomy. But after clicking submit, a bunch of errors... It worked fine with a simple textfield though.

Notice: Undefined index: #field_parents in field_widget_field() (line 546 of /MYSITE/modules/field/field.form.inc).
Notice: Undefined index: #field_name in field_widget_field() (line 546 of /MYSITE/modules/field/field.form.inc).
Notice: Undefined index: #language in field_widget_field() (line 546 of /MYSITE/modules/field/field.form.inc).
Warning: Invalid argument supplied for foreach() in taxonomy_autocomplete_validate() (line 1643 of /MYSITE/modules/taxonomy/taxonomy.module).
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 2: SELECT base.tid AS tid, base.vid AS vid, base.name AS name, base.description AS description, base.format AS format, base.weight AS weight, v.machine_name AS vocabulary_machine_name FROM {taxonomy_term_data} base INNER JOIN {taxonomy_vocabulary} v ON base.vid = v.vid WHERE (base.name LIKE :db_condition_placeholder_0 ESCAPE '\\') AND (base.vid IN ()) ; Array ( [:db_condition_placeholder_0] => calendar ) in DrupalDefaultEntityController->load() (line 196 of /MYSITE/includes/entity.inc).
t-lo’s picture

All issues from http://ventral.org/pareview/httpgitdrupalorgsandboxtomclopez1878728git sorted.

I'll look into the errors later today, thanks @ahlofan for testing and the positive feedback!

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

I'm a robot and this is an automated message from Project Applications Scraper.