Hi!
I´m trying to change a specific nodetype form. Now I need to unset some field in node/edit, but not in node/add.

Is there a way to do that?

I´ve tried the following in template.tpl, with no luck:

function clearblue_theme() {
  return array(
    'news_node_form' => array(
    'arguments' => array('form' => NULL),
    ),
	);
}


if ((arg(0) == 'node') && (arg(2) == 'edit')){
  $node = node_load(array('nid' => arg(1)));
return $messages;
unset($form['field_news_date']);
return (drupal_render($form));
}

Thanks!!
Rosamunda

Comments

Rosamunda’s picture

Could I create a little module with something like...this?

<?php
/**
* Implementation of hook_form_alter().
*/
function MY_MODULE_form_alter(&$form, $form_state, $form_id) {
  if ((arg(0) == 'node') && (arg(2) == 'edit')){
  $node = node_load(array('nid' => arg(1)));
  //want to unset a specific field at the node/edit form (and NOT at node/add)
  unset($form['field_FIELD_NAME']);
  //want to unset the button "delete"
  unset($form['buttons']['edit-delete']);
  }
}
?>
Rosamunda’s picture

Title: Whet if I need to show a field in node/add but unset or hide it in node/edit? » What if I need to show a field in node/add but unset or hide it in node/edit?

Sorry for the typo...

voxpelli’s picture

This looks like a situation that certainly should be supported.

I've been talking with Hugo about it and he agreed - I'm unsure when he will have time to work on it though.

Rosamunda’s picture

Yes, I think that the possibility to manage forms using template.tpl shouldn´t be eliminated. This module provides a tpl form... maybe adapting it according to it´s name?

Thanks!!
Rosamunda

Rosamunda’s picture

Maybe something can be done aading some Rules (with Rules module...)?

Rosamunda’s picture

I´ve tried with rules, and it successfully managed it.
But the problem remains unsolved because sometimes people could need for this module to take care of the node/add form but not the node/edit form.

Let me explain:
I´ve created a special tpl to edit the form of a specific nodetype.

in template...
....
'page_node_form' => array(
'template' => 'edit-page',
'arguments' => array('form' => NULL),
    ),
....
.....
......
function clearblue_preprocess_page_node_form(&$variables) {
  $variables['intro_text'] = t('');
  $variables['rendered'] = drupal_render($variables['form']);
} 

And I´ve created the file according to what I specify in template.tpl.
In that file, I want the form to appear normally inside node/add, but to hide all values in node/edit unless you´re the admin.
That works OK, but in node/add the settings inside /admin/content/node-type/page/form dissapear, I mean, the form is shown in the ugly normal default way.

<?php 
// Use the normal form in node/add
if ((arg(0) == 'node') && (arg(1) == 'add')){
$node = node_load(array('nid' => arg(1)));
return $messages;
return $rendered;
}

global $user;
// The node/edit form will appear only to admins
if (is_array($user->roles) && in_array('admin', $user->roles)) {
// This code will control only node/n/edit and NOT node/add
if ((arg(0) == 'node') && (arg(2) == 'edit')){
  $node = node_load(array('nid' => arg(1)));
return $messages;
return $rendered;
}
} 
else {
// but if you´re not an admin...
print '<h3>Oops! You cannot edit this content.</h3>';
}
?>

Yes, I know that the edit perm is available bu default, but if you enable organic groups and want the groups to be private (so you need to OG perm to take control), the group manager will be able to edit all content inside a group, no matter what you do to prevent it. OG perms override normal default perms.

What Can I do? Any suggestions?

THANKS!!!

Rosamunda

asherry’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)
Issue tags: +EOL

end of life for d6, it won't be supported. Thanks for your work though.