I love VBO.

My problem is that "None" is showing up as a choice in a select list for a required field that has a list of allowed values and a default set. And if you choose "None" and click on modiefied selected nodes, it actually empties those fields and leaves them without a value even though they are required fields.

The node/add and node/edit forms exactly as you would expect from a required field.

Help, anyone?

Thanks,

Shai

CommentFileSizeAuthor
#5 962670-2.patch765 bytesitangalo
#3 962670-1.patch751 bytesitangalo

Comments

Shai’s picture

I found this in the CCK issue queue: #200359: No defaults with node_save();

I think it might be related. It's still open.

I'm also open to workarounds... like maybe some kind of form_alter to get the "none" choice to go away.

Shai

itangalo’s picture

I had the same problem, and I tracked this behaviour down to line 74 in fields.action.inc: $field['required'] = FALSE;

I think this is very intentional, though – when looking at more of the code I conclude that it is also used for multiple-value fields, including the ability to only add new values (and not replace the existing ones). If the fields were required, you would always have to set a new value to all the processed nodes – while leaving it empty allows not affecting (required) multiple-value fields.

There are three possibilities to solve this, as far as I can see:

1) Keeping the current code and taking care of Shai's and my problem by a form_alter. This is good if I'm having the edge case.
2) Change the code to respect required fields, and forcing those who want to use multiple-value fields in the way described above to do form_alters. This is good if they're having the edgiest use case.
3) Change the code to check whether the field is a required multiple-value field, and only then unset the required condition.

I'll make some experiments and return with the results.

itangalo’s picture

Status: Active » Needs review
StatusFileSize
new751 bytes

I went along track 3 above. Attached is a simple patch that moves the required=FALSE to only multiple-value fields.
Note that this patch will force the user to set fields even fields that will not be used on the update (which may be the case if you're updating many fields at once). This is a feature, not a bug. ;-)

itangalo’s picture

Version: 6.x-1.9 » 6.x-1.10
itangalo’s picture

Version: 6.x-1.10 » 6.x-1.x-dev
Category: support » feature
StatusFileSize
new765 bytes

...patch now with --no-prefix to make it easier to apply with the -p0 option. Also rerolling patch against dev.

bojanz’s picture

Assigned: Unassigned » infojunkie

Assigning to infojunkie for review.

infojunkie’s picture

Assigned: infojunkie » Unassigned
Status: Needs review » Needs work

The fact that

this patch will force the user to set fields even fields that will not be used on the update (which may be the case if you're updating many fields at once)

make the UI counter-intuitive. A better solution is needed.

kenorb’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)