By yan on
Does somebody know a way to disable a checkbox once it has been checked and the node has been saved?
I have a CCK single on/off checkbox with PHP allowed values (either 0 or a value from the database). I want to allow users to 'activate' the checkbox, but once they save the node and edit it, they shouldn't be able to uncheck it.
i.e. if the active value is 0, allow selection, if it is different from 0, not.
Comments
For this example, we're
For this example, we're assume that the checkbox field name is 'some_module_checkbox':
Also I recommend to use
#accessinstead of#disabled. If you provide some code snippets, the people could help you better.API Reference:
http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....
http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....
Thanks Sepher. Just a little
Thanks Sepher. Just a little confusion: Does "some_module" mean the name of a custom module? Or does it mean the name of the CCK field affected? In the second case, where would I place this code?
Yes some_module means a name
Yes some_module means a name of your custom module, You need to use a hook_form_alter in order to validate and add a submit function for your node form.
Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form
Great, with some help from
Great, with some help from here I got to the following code which works for me:
Thanks!