1

I have Drupal 7 site. It has custom content type Product. It has 20 fields. I want to control the UI of the add/edit form for this content type.

I created a module under sites/all/modules.

  • admin_product
    -admin_product.info
    -admin_product.module

-admin_product.module

 <?php
 function admin_product_theme($existing, $type, $theme, $path){
 return array(
'product_node_form' => array(
  'arguments' => array(
      'form' => NULL,
  ),
  'path' => drupal_get_path('theme', 'myTheme').'/templates/forms',
  'template' => 'product-node-form',
  'render element' => 'form',
  )
  );
  }

In the templates - sites/all/themes/myTheme/templates/forms/product-node-form.tpl.php

-product-node-form.tpl.php

 <?php
 echo drupal_render_children($form);
 echo 'hello template';  // just to test
 ?>

The template is not rendered.

How do I control the UI of the form.?

Any help highly appreciated.

2 Answers 2

1

I think all you need is Field Group module. With the help of this module you can organize all your fields in groups (i.e. divs, tabs etc.). The rest stuff can be made by CSS.

Other way is to use hook_form_FORM_ID_alter() hook, or, specifically, hook_form_node_form_alter(), to alter your form.

Anyway, in Drupal 7 Form API differs from Theme API, and the code you provided just has no sense :) Sorry for this :)

0

If the theme you're adding this to is not the default admin theme for the site then the template won't get picked up in the admin area.

You'll have to add this code to a custom module or create a sub-theme based on the administrative theme (e.g., Seven) and select that as your admin theme and put the code there.

Good explanation found here: https://drupal.stackexchange.com/questions/33253/how-do-you-theme-a-content-types-create-edit-form-in-drupal-7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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