I am using this module with auto nodetitles and realized I can't set an auto nodetitle from a field that is hidden. Auto nodetitle will only take a form value.

What I was wondering is if it's possible to disable a form field, rather then hide it? The User Read Only module does this and it works. By disabling the field, it would allow other modules access to the field values, but not allow the non-permissioned role to edit the field.

If I wanted to create a patch that did this, where would I start?

Comments

infojunkie’s picture

Hello,

If I understand your question correctly, you want to use an auto_nodetitle that uses one of the fields made invisible/uneditable. And to do so, there should be a field in the form that carries the original field value.

The form altering is done in the function workflow_fields_node_form_alter(). In it, there's a loop that iterates over all fields that need to be hidden/disabled and that alters the corresponding form element accordingly. If we want to hide a field, I simply set its element's #access attribute to FALSE, and create a dummy element of #type = 'value' that carries the default value as defined in the CCK form. That new element's name is "original_field name_default_value". In the case of disabled field, I invoke the CCK field rendering function to display its value, and still create that new default value element.

So the simplest solution would be to change the default value element from #type = 'value' to #type = 'hidden'. Then, let auto_nodetitle read from that default value field.

If that doesn't work, then we should find a way to change the form altering logic such that the original field becomes 'hidden' instead of a new default field. I can't remember why I didn't take that route to begin with, so I can't tell you if there's a problem with this approach :-)

Hope that helps!

btully’s picture

subscribing

abhaga’s picture

Wouldn't it be a better idea to 'disable' the fields rather than render them? This is especially relevant when using CCK fields. Some of the CCK fields like Filefield do not return anything on rendering and so corresponding fields simply disappear which can be confusing for the user.

I have taken the route of disabling the fields where all the fields can still be seen but are greyed out. I can provide the code if you are interested in going in that direction.

infojunkie’s picture

Sure, send the patch and I'll try it out!

amaria’s picture

Any progress on this? I'm running into the same issue.

tebb’s picture

subscribing.

infojunkie’s picture

Assigned: Unassigned » infojunkie

I'm working on this issue. It turned out to be quite deep so thanks for your patience.

infojunkie’s picture

Status: Active » Fixed

Fixed in latest 5.x-dev release. Auto_nodetitle seems to be working. Please try it out thoroughly because a lot had to change under the hood.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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