By Lanny-1 on
I would like to alter the following code in modelu private
function private_form_alter($form_id, &$form) {
if ($form['#id'] == 'node-form') {
if (user_access('mark content as private')) {
$form['private'] = array(
'#type' => 'checkbox',
'#title' => t('Private'),
'#return_value' => 1,
'#description' => t('Check here if this content should be set private and only shown to authorized users.'),
'#default_value' => $form['#node']->private,
);
}
else {
$form['private'] = array(
'#type' => 'hidden',
'#value' => $form['#node']->private,
);
I'd like to be able, ideally, to hide the form and default the value as if the checkbox were clicked at the time the node is created. I'd like to show the form on $op = 'update".
The purpose of my modification is to force each node to state private and only use the checkbox to un-private the node.
Thank you.
Comments
check for nid
I think the easiest way to see if it's a new node is to check whether
$node->nidis set (or whether$node->privateis set).Also, for the hidden info, it's better to use
'#type' => 'value'rather than'#type' => 'hidden'something like this:
---
Work: BioRAFT
Re: check for nid
Thanks for your response... What you are showing is great (though it would need debugging) but it is not what I need. What I need is to force the process of checking a box and actioning what follows - that is, concretely, inserting a record into table 'private' for each node which is not a story or a page.