Comments

amitaibu’s picture

StatusFileSize
new2.83 KB

Move the code after the previous action, and call #after_build only once.

amitaibu’s picture

StatusFileSize
new2.78 KB

Had a typo...

markus_petrux’s picture

Status: Needs review » Closed (won't fix)

Ugh, I think this is not something I would like to see in CCK package. The trick I documented in the handbook could not work for all form elements, it may need slight variations, and this would mean a can of worms that's not desired in CCK due to the huge user base.

Maybe you could write this as a contrib module?

klausi’s picture

Title: Rules action - disable cck field » Rules action - disable a form element
Project: Content Construction Kit (CCK) » Rules
Version: 6.x-2.x-dev » 6.x-1.x-dev
Component: Rules Integration » Forms Support
Status: Closed (won't fix) » Needs work

Bringing this back home to Rules Forms.

I think you should do it in a more generic way - make it possible to disable *all* form elements, like it is possible to hide all types of form elements. Do a patch for rules_forms.rules.inc and add your action there.

amitaibu’s picture

Well, the thing is that disabling a CCK field isn't working the same as FAPI, that's why I thought of that patch.

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new2.5 KB

And here it is...

klausi’s picture

Status: Needs review » Needs work

Good, the period in "Disable an element of the form." is a little bit annoying, please remove it.

Apart from that the patch looks clean and works for me.

Regarding CCK: have a look at rules_forms_action_adjust_weight(), we already do a small CCK hack there, so maybe it works in a similar way for disabling fields?

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new2.5 KB

Yeah, I saw the CCK hack, but it won't do for disabling. As you can see in http://drupal.org/node/357328 - there no real straightforward way of doing it. I assume It will be solved in D7 when we'll have fields in core.

klausi’s picture

Status: Needs review » Active

Thanks, committed to CVS.

Now we should think about the ugly CCK stuff ... do we want this also in the Rules Forms module?

Setting the issue back to active.

klausi’s picture

Assigned: Unassigned » klausi
Status: Active » Needs review
Issue tags: -rules integration +gsoc:rulesmonkey
StatusFileSize
new4.52 KB

And here comes the support for CCK fields and other form elements that are not known during hook_form_alter() yet.

The patch also improves the element ID annotations on forms ("Container" form elements are not called "Hidden" anymore).

amitaibu’s picture

Markus wrote:
> The trick I documented in the handbook could not work for all form elements

So even if we use it maybe it's worth mentioning in the description some kind of warning. Although we can ask markus to explain when his 'trick' will not work.

klausi’s picture

StatusFileSize
new5 KB

New patch: Removed "Note that this will not disable CCK fields" from the description.

If you look at form_builder() and _form_builder_handle_input_element()
http://api.drupal.org/api/function/form_builder/6
http://api.drupal.org/api/function/_form_builder_handle_input_element/6
you see that disabled elements are expanded in the same way as we do:

if (!empty($form['#disabled'])) {
  $form['#attributes']['disabled'] = 'disabled';
}

So we can assume that this will work for all form elements for now.

amitaibu’s picture

Seems ready to be committed.

fago’s picture

Status: Needs review » Reviewed & tested by the community

I think so too :)

klausi’s picture

Status: Reviewed & tested by the community » Fixed

committed to CVS.

Status: Fixed » Closed (fixed)
Issue tags: -gsoc:rulesmonkey

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