I did the following, with autocomplete_deluxe from 14-oct-2011 on D7.9:
Add a field to a Content type:
- add a term refence field to a content type;
- this field is NOT required;
- used the Autocomplete Deluxe widget;
- automatically, the field 'Autocomplete settings' is set to 'Allow and insert new terms';

Create a new node:
- the term reference field is default empty; this is OK.

Go to the field settings:
- set the field 'Autocomplete settings' to 'Deny any new terms';
- the 'The default value for this field, used when creating new content.' is now set to a term. I have no means to make it empty.
- Save the field/content type anyway.

Create a new node:
- the term reference field is now filled with the default value; this is NOT OK.

IMO, the default term value can be empty in any of the combinations Required=yes/no + New terms=Deny/Allow

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rooby’s picture

I can confirm this problem.

rooby’s picture

This is a quick hack of a fix that buys me some more time.
It isn't a proper fix but it does the job for me.

It doesn't stop the default widget on the field settings page from automatically selecting the first term but it gives an empty default value for the field when adding content, which is what I need.

sepgil’s picture

Component: Code » Single list - deny new values
Assigned: Unassigned » sepgil
FileSize
1.33 KB

I think an empty default value should only be allowed if field is not required. Else a default value must be selected. Therefore I think the patch should look similar like this:

johnv’s picture

@sepgil,
i don't agree. Even with required fields, it is possible to NOT supply a default. For the following reasons:
- Not supplying a default forces the user to make a choice. otherwise they'll be lazy and accept the default.
- Standard Drupal does it the same way.
ofcourse, admin can always set the default when required.

johnv’s picture

Status: Active » Needs review
sepgil’s picture

@johnv: yeah that makes sense, but at least you should not be able to select nothing(like its currently possible with the lateset patch) if the field is required...

johnv’s picture

Correct, required is required...

rooby’s picture

I agree with #4 & #6.

sepgil’s picture

I made a new patch, which only add an empty option if the field cardinality is 1 and if the field is not required. Please try it out.

sepgil’s picture

The last patch... was not a good one...
This new patch solves this issue and the issue #1433876, since they are somehow connected.
Compared to my last patch, this one will not display the empty value for selection, since it somehow looked, like there was a bug.
Please test it out, and give me feedback!

johnv’s picture

@sepgil #10, you mean #1433876: Fix handling of new terms ?
Shouldn't that one be marked as a duplicate, then ?

I'd prefer to keep this issue small & simple: make sure the default_value should to be OK, with or without this module.

I didn't get this working, but I now understand the misunderstanding: you proudly use your own widget for the 'default value' on the field settings page. This is nice, but makes the widget more complicated.
On the settings page, the default value is not required, even if the field is required.
We need an unambiguous way do see in which of 2 screens we are.
Perhaps we should throw in a hook_form_field_ui_field_edit_form_alter(&$form, $form_state) , so we can make a difference between edit page and settings page?

        $options = autocomplete_deluxe_allowed_terms($field);
//        $options = array('' => '') + autocomplete_deluxe_allowed_terms($field);
//        $options = (empty($element['#required'])  && empty($multiple) ? array('' => '') : array()) + autocomplete_deluxe_allowed_terms($field);
//        $options = (isset($element['#required']) ? array('' => ' ') : array()) + autocomplete_deluxe_allowed_terms($field);
rooby’s picture

The patch in #10 works for me.
Thankyou.

rooby’s picture

Maybe I spoke too soon.

I also have non-taxonomy select fields using autocomplete deluxe.

I have one field that is not required and has 2 allowed values and every time I set the default to blank it selects the first value.

In this case for me it isn't that much of an issue but it is probably something that needs addressing.

rooby’s picture

Component: Single list - deny new values » Single values
Issue summary: View changes

Now that this module doesn't support deny new terms this should be closed right?

LNakamura’s picture

Status: Needs review » Closed (outdated)

@rooby - correct! Closing as outdated.

LNakamura’s picture

Note that if you want to prevent the adding of new terms in a 2.x Autocomplete Deluxe widget, Content Taxonomy will do the trick.