The issue was raised in this question. Why not exploit the advantages that template files offer in the case of forms?

  • 1
    We should not avoid this! If you care about the presentation of any particular form, create a tpl for it. – Charlie Schliesser Feb 10 '15 at 16:12

I can see no good reason for not using a template file to theme a form. As I stated in that question, the simple #prefix and #suffix tricks might not be enough, say if you wanted the entire form to be a table rather than div based. I've used drupal_render with a form element parameter in a template to draw the individual fields in the form, but make sure you call drupal_render without an argument at the end of the template to populate the rest of the form, such as the form hash etc. as it won't validate.

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.