I would like to do a form_alter and change a form element into an autocomplete deluxe, but it does not work fully for now.

Putting the element to #type => 'autocomplete_deluxe', I havec #autocomplete_options working quite well, but not #autocomplete_deluxe_path for now (it works well for simple autocomplete field though). There is a special formatting for such autocomplete path ? Or there is something more to do ?

Comments

open social’s picture

'#autocomplete_deluxe_path' => url('autocomplete_deluxe/taxonomy/field_categories', array('absolute' => TRUE)),

something like this will do

zulfierken’s picture

I am trying to use autocomplete deluxe in a form.

$form['order_creation']['account_owning_order'] = array(
'#type' => 'autocomplete_deluxe',
'#title' => t('Choose User'),
'#autocomplete_options' => $options,
'#multiple' => FALSE,
'#value' => $options,
'#autocomplete_min_length' => 2,
);

My options are:

Array
(
[0] =>
[10010101] => 10010101 James Lopez
[10010102] => 10010102 Martin Lopez
[10010103] => 10010103 Andy Hope
)

My result is:

[account_owning_order] => 0
[textfield] => 10702 John Doe
[list_value] => 0

Normally, it should return array key as textfield value. Is there anything that I am missing?
By the way, I had to add a null array because default value does not work

118218’s picture

Thank you for your module, it's very nice!

I am currently building a module, and I'd use fields "autocomplete deluxe".

How do I?

hass’s picture

Status: Active » Fixed

Sounds like the question has been answered.

Status: Fixed » Closed (fixed)

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

mstef’s picture

Version: 7.x-1.0-beta5 » 7.x-1.0-beta7
Status: Closed (fixed) » Active

Updated to beta7, and this no longer works. I use #type => 'autocomplete_deluxe', the widget appears like it should, but you cannot enter text into the field, and the drop-down button doesn't do anything when clicked.

Odd because the diff between beta6 and 7 doesn't seem like it would affect this. Perhaps the mistake is on my end?

mstef’s picture

Status: Active » Closed (fixed)

My mistake.. as expected

nortmas’s picture

zulfierken, you should replace $element['textfield'] to $element[$element['#name']] in functions autocomplete_deluxe_element_process and autocomplete_deluxe_after_build

zulfierken’s picture

Version: 7.x-1.0-beta7 » 7.x-2.0-beta2
Component: Documentation » Code (miscellaneous)
Priority: Normal » Major

I just tried to use 7.x-2.0-beta2 version programmatically;

$form['choose_user_id'] = array(
'#type' => 'autocomplete_deluxe',
'#title' => t('Choose User'),
'#autocomplete_options' => $options,
'#default_value' => 'select',

'#multiple' => FALSE,
'#size' => 40,
'#autocomplete_min_length' => 2,
);

And unfortunately, it shows a simple textfield without ajax.

How can I choose options with autocomplete? or How can I use this version programmatically?

franz’s picture

I had to add "#parents" => array($element['#name'], 'value_field'), on $element['value_field']

Alexander Matveev’s picture

Great module, thank you!

But how can I set default value with '#autocomplete_deluxe_path'?

$form['contacts_autocomplete'] = array(
    '#title' => 'Test',
    '#type' => 'autocomplete_deluxe',
    '#autocomplete_deluxe_path' => url('contacts/autocomplete', array('absolute' => TRUE)),
    '#multiple' => false,
    '#autocomplete_min_length' => 1,
  );

I mean, if my json values are:

{
1: 'one',
2: 'two'
}

And I must display 'one' as field default value, but somewhere must be '1' set as key.