Hi Everybody,

I am a newbie in the drupal module development world. My requirement is that i want to hide all the details like 'Publishing options', 'menusettings', 'authoring information' etc while the user is creating my node type. I have achieved that by creating my own node creation form and using node_save in its submit callback function.

But now the problem is with the node editing form (node/xx/edit). Drupal again defaults to its node creation form when i click the edit button. It displays all the above said information in that. How to tell drupal to display my form in the edit option too?? and how to add a preview option to my form??

Please help me with this.. I searched a lot but was not able to find an answer to this...

Comments

mileZ’s picture

Hi manujoseph,

read this post: http://drupal.org/node/101092

I think you are looking for a solution like this.

mileZ
Seo Web

manujoseph’s picture

Hi mileZ,

Thanks for your help.. That post was a very good way of achieving what i wanted.. Thanks a lot for that.. But i found that a lil too complex to implement.. I found another slightly non-elegant way of doing it.. I decided to use hook_form_alter.. I am adding the code below

/**
* Implementation of hook_form_alter()
* This hook is used to alter the domain form before rendering so that
* unwanted details are hidden from the user
*/
function domain_form_alter($form_id,&$form)  {
  if( $form_id == "domain_node_form" )  {        
    // the following hides the unwanted details from the user
    // so that the user has to fill only the necessary details
    $form['author']['#type'] = 'hidden'; 
    $form['options']['#type'] = 'hidden';
    $form['comment_settings']['#type'] = 'hidden';
    $form['menu']['#type'] = 'hidden';
    $form['path']['#type'] = 'hidden';
    
    //  $form['form_info'] = array(
    //    '#value' => '<pre>'. print_r($form, TRUE) .'</pre>'
    //  );
  }
}

Any mistakes here or any ways of improving it??

kobnim’s picture

Hi,
I am using hidden form elements as described above. They are working fine, with one big exception. When I set

$form['options']['#type'] = 'hidden'

the node shows up as "not published", even though the default "published" value is TRUE:

[options] => Array
        (
            [#type] => fieldset
            [#access] => 1
            [#title] => Publishing options
            [#collapsible] => 1
            [#collapsed] => 1
            [#weight] => 25
            [status] => Array
                (
                    [#type] => checkbox
                    [#title] => Published
                    [#default_value] => 1
                )
            ...

Any ideas what might be wrong?

Thank you.

SL.CWolff’s picture

When you use
$form['options']['#type'] = 'hidden';

you're actually changing the type, which could reset the value. Try:

$form['options']['#access'] = 0;

This should keep the default value

chetan-singhal’s picture

which form you want to hide you can use

<?php
$form[$key]['#access'] = 0;
?>

or you can write your own tpl.

chetan

qqboy’s picture

if access is 0
then it will be loaded from database or not
if yes,
then still a burden for server.

i am wondering why not unset

i also have one question,
if in webapp, i want to delete some elements as early as possible,
how and where should i do

thanks.