How to Theme textfield for one page?

idontknowtheanswer - November 21, 2008 - 17:13

As usual I'm sure this must be easy but I can't find the answer!

By default for a TextField (or TextArea, Taxonomy and most other things seemingly) it outputs the Title, textbox and the description in that order. I simply want to change the order so it outputs Title, Description and textbox.

I've looked at theme_textfield but that calls theme_form_element which is the theme that orders the title and description. I only want to change the order for certain pages though so overriding theme_form_element doesn't seem correct.

Can anyone point me in the right direction please?

TIA.

Sorry, should say that I'm

idontknowtheanswer - November 21, 2008 - 17:28

Sorry, should say that I'm not talking about CCK here. I'm referring primarily to the default Title field.

If you know how to do CCK as well though that'd be great!

Anyone? Is this really so

idontknowtheanswer - November 23, 2008 - 16:57

Anyone? Is this really so hard in D6?

...

Jeff Burnz - November 24, 2008 - 00:15

There are quite a few tutorials for modding forms in Drupal, I know 11heavens site has a good one about the contact form (theory is the same) Lullabot have a strait forward run down also for both D5 and D6.

Thanks, I'll have another

idontknowtheanswer - November 24, 2008 - 10:03

Thanks, I'll have another look. I've probably been through them already to be honest - I've got the Drupla 6 Themes book sat next to me as well. The problem with themeing the contact, search, profile page form examples is that they focus on a single, self contained form. The node/add form is a combination of multiple fields pulled from several sources (CCK, core) so the challenge to theme that seems (to me anyway) much more complex.

The problem I'm struggling with is the way that theme_textfield explicitly calls theme_form_element, it essentially chains several theme calls together. I'm actually happy with what theme_textfield spits out, it's the stuff that theme_form_element wraps round it that I don't like (it orders the title, description etc).

If I could just override theme_form_element for a single page my world would be complete! I only want to do it for the node/add/type page(s). I don't want the change to ripple through all the site.

In case anyone's interested

idontknowtheanswer - November 24, 2008 - 14:31

In case anyone's interested I found an answer (notice I don't say _the_ answer) by looking at the WordPress Comments module (http://drupal.org/project/wp_comments). It basically does what I was asking and overrides theme_form_element for certain situations. The part I'm uncomfortable about is the hard coded call to theme_form_element(...), that to me suggests it will bypass any attempts to theme form_element elsewhere because it circumnavigates the logic that the call theme('form_element'...) makes.

 
 

Drupal is a registered trademark of Dries Buytaert.