0

I am using bartik responsive theme. I made a sub theme of the theme. I enabled the sub theme as the default theme. I have given access to anonymous users to add webform content at xxx.com/node/add/webform. Users see the title field as required. I like to remove the title field of web form so users dont need to enter the title.

I found this link but I could not follow it all the way:

link.

  • "You need to have both node.tpl.php and node-webform.tpl.php in your theme directory for this to work. Also make sure you clear your Drupal caches after copying the files in."

I went to theme directory(theme/xx/templates) and I see bartik, engines, garland, stark, seven. I dont see my sub theme and bartik responsive there. What would be my theme directory in my case?

I simply went to theme/bartik/template> copied node.tpl.php to node-webform.tpl.php and then added

<?php if ($page == 0): ?>
  <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>

I still see the web form title field for public users at xxx.com/node/add/webform.

Do you know how I can remove the title field for web form module?

2

If you don't mind installing another module:

  1. Install Automatic Nodetitles
  2. Go to admin/structure/types/manage/webform/auto_label
  3. Select a default title and check "Automatically generate the label and hide the label field"
  4. Profit!
  • You need both modules, of course! You install this new module just to automagically assign a title to the webform and hide it at the same time – user1527576 Aug 17 '15 at 0:06
2

I know this has been answered but I wanted to also offer a "DIY" alternative (as opposed to installing a module):

Implement hook_form_alter in your theme's template.php file:

function mytheme_form_alter( &$form, &$form_state,$form_id ){
  if ($form_id == 'webform_form_id') {
    // Prevent access to this field.
    $form['submitted']['form_component']['#access'] = FALSE;
  }
}

You will likely also need to set a default value on the field since it is required.

Source: Programmatically modifying a webform with hook_form_alter()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.