Support from Acquia helps fund testing for Drupal Acquia logo

Comments

karlkablisk2’s picture

No answer yet? :(

Mike Draconid’s picture

FileSize
875 bytes

i have modified it to support multiple by adding
'#multiple' => TRUE,
in form API

Mike Draconid’s picture

FileSize
915 bytes

updated, for a bug fix

estoyausente’s picture

Status: Active » Reviewed & tested by the community

#3 Code works correctly, and the field is rendered correctly too. Thanks.

dwebpoint’s picture

Status: Reviewed & tested by the community » Needs work

#3 works for element which was created with Form API only. It doesn't resolve the issue.

botris’s picture

This code, instead of the snippet in #3, enables the multi value widget for me:

  $field_info = field_info_field($element['#field_name']);
  if ($field_info['cardinality'] != 1) {
    $element['#attributes']['multiple'] = 'multiple';
    $element['#attributes']['name'] .= '[]';
  }

But it does not yet save the value.

botris’s picture

The I'm using a.t.m. is to process the results in a validate function next to using #6:

  // First item in array in Null, remove that one
  array_shift($form_state['input']['my_field'][LANGUAGE_NONE]);
  foreach ($form_state['input']['my_field'][LANGUAGE_NONE] as $item) {
    // Set the values
    preg_match_all('/\((.*?)\)/', $item, $matches);
    $form_state['values']['my_field'][LANGUAGE_NONE][]['target_id'] = $matches[1][0];
  }
EugeneChechel’s picture

@botris where did you put your code? Could you please share an example?

botris’s picture

@EugeneChechel so I used this code in a custom form, and it works for submissions, but when editing an existing form I got in real trouble :)
So after a while of debugging I decided it was too much time to work around, so I don't use Chosen ajax anymore, the combination I use now that works really well is:
https://www.drupal.org/project/autocomplete_deluxe
with https://www.drupal.org/project/acdx_references
patched with https://www.drupal.org/node/1295034#comment-10329839

If you do decide to stick with Chosen ajax you would put the part from #6 in your form code or when altering an existing form in a hook_form_alter().
The code from #7 would go in a form validation function.
Hope that helps.

chertzog’s picture

Here is a patch that makes this work for me.

monstrfolk’s picture

FileSize
865 bytes

Patch was created incorrectly. I fixed the patch and remove unneeded code.

monstrfolk’s picture

Status: Needs work » Needs review
monstrfolk’s picture

FileSize
3.68 KB

This issue is fixed. I would really appreciate it if anyone could test this. Perhaps @Mike Draconid, @botris, @chertzog, or anyone else that gets this message could test.

monstrfolk’s picture

FileSize
4.51 KB

Small change to patch that removes the size attribute from the select html tag. Adds 'form-select' class to the html select element to conform with Drupal.

monstrfolk’s picture

FileSize
4.51 KB

One more fix when using chosen ajax single item.

Notice: Undefined index: multiple in chosen_ajax_theme_textfield() (line 219 of /sites/all/modules/chosen_ajax/chosen_ajax.module).

monstrfolk’s picture

FileSize
7.82 KB

Updated patch. Solves many issues.

monstrfolk’s picture

FileSize
7.89 KB

A fix for single chosen when creating new content.

monstrfolk’s picture

FileSize
7.83 KB

More updates and changes.

monstrfolk’s picture

FileSize
7.73 KB

Removed watchdog output.

monstrfolk’s picture

FileSize
7.73 KB
monstrfolk’s picture

FileSize
9.14 KB

New patch. Everything should be good with this one.

Tested with....
autocomplete, cardinality 1, non fixed display
autocomplete, cardinality unlimited, non fixed display
autocomplete, cardinality 1, fixed display
autocomplete, cardinality unlimited, fixed display
autocomplete, cardinality 1, non fixed display, required
autocomplete, cardinality unlimited, non fixed display, required
autocomplete, cardinality 1, fixed display, required
autocomplete, cardinality unlimited, fixed display, required
autocomplete tags, cardinality 1, non fixed display
autocomplete tags, cardinality unlimited, non fixed display
autocomplete tags, cardinality 1, fixed display
autocomplete tags, cardinality unlimited, fixed display
autocomplete tags, cardinality 1, non fixed display, required
autocomplete tags, cardinality unlimited, non fixed display, required
autocomplete tags, cardinality 1, fixed display, required
autocomplete tags, cardinality unlimited, fixed display, required

monstrfolk’s picture

FileSize
8.58 KB
monstrfolk’s picture

Any updates?

  • dwebpoint committed f9b1028 on 7.x-1.x
    Issue #2217629 by monstrfolk: Autocomplete (Tags style) doesn't allow...
dwebpoint’s picture

@monstrfolk thanks a lot for the patch.

monstrfolk’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.