开发者

Changing the value of a field in a Drupal form

I've created a hook submit function for my Drupal node edit form. I'd like to change the value of a CCK field (not in the form) for that specific node within the sumbit handler.

I've tried setting the field as hidden and applying a value to it, but this did开发者_如何转开发n't work.

Could anyone suggest a way to do this?

Thanks,

Jonathan


I think you're probably over complicating things. If all you want to do is change the value of a CCK field on Node save (perhaps based on certain conditions) you're probably better off using the Rules module ( http://drupal.org/project/rules ). There are plenty of videos and resources on the internet on the Rules module.

Also if you want to hide a particular CCK field you can use the Content Permissions module that is bundled with the CCK module. You can deny the user edit access on the CCK field but grant view access.


Instead of adding a submit function to an edit for, why don't you use hook_nodeapi and perform your logic when the $op = 'presave'? This way you don't need a heavy module like rules, but can still alter the values on node submission.

EDIT: Take a look at hook_nodeapi()


use form_set_value(); function on form validation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜