Form handling not compatible with CCK field permissions?

PeteS - February 5, 2009 - 20:42
Project:Chaos tool suite
Version:6.x-1.0-alpha2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I have a simple case where I want to disable access to a field with the CCK content field permissions module. The normal behavior, without ctools installed, seems to go like this:

1. hook_field_access returns false for a field of my choosing
2. The form renders without the field, because the field permissions module has set #access = false, which then causes #type = value, which makes it so that the field is stored internally-only, rather than as a text box or a hidden formfield.
3. Some Drupal form mechanism that I don't fully understand allows the form to pass validation even though the field was not necessarily provided by the user.
4. Save, and everything is fine.

When ctools is installed, it results in this chain of events:

ctools_build_form gets called, then ctools_process_form, then ctools_validate_form. The last function calls _form_validate(), which seems to all be happening too early in the process, because calling _form_validate() at that point results in a "XYZ field is required." message.

In general this is confusing and hard to deal with because:

1. I'm have no handlers specified for node/edit, which I understand to be a default "Page" implemented by CTools. So why is it doing even a single thing to the normal flow of form execution?
2. If I were overriding node/edit with CTools, I would expect that the default Drupal behavior would be maintained 100%, and only some additional actions would be performed on top of the default processing, and only after the fact.

I would expect that any changing of #2 would result in some pretty crazy unanticipated consequences, much like the field permissions stuff not working.

My fix, for now, by the way, is to just put a return; early on in the ctools form processing. I'm sure I'm breaking ctools' ability to intercept node/edit pages, but since I don't need them for my project ATM, that will work. (But there are plenty of other projects lined up where it may be nice to modify node/edit, so in general I'd like for the feature to be available, but not if it means that I have to jump through hoops to get other simpler modules to work.)

But of course, it's entirely possible that I'm confused and/or not describing this accurately, or missing an easy fix. So, does anyone have any ideas?

#1

PeteS - February 5, 2009 - 20:44

#2

merlinofchaos - February 5, 2009 - 20:51

Hm, that's interesting. If you don't have an override for node_edit, I'm not sure why ctools_build_form is actually being called for that form. That should only happen if you've actually got a panel doing an override. Very curious.

And yes I do think it may be related.

#3

merlinofchaos - July 17, 2009 - 21:59
Status:active» fixed

I think this is fixed in the latest incarnations.

#4

System Message - July 31, 2009 - 22:00
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.