views:

43

answers:

2

Correct me if I'm wrong, after reading drupal fapi related articles, I got the impression that fapi generates 'id' attributes by itself. It allows developers to assign 'name' attribute only. If that's the case, is there a way I can set desire 'id' value for elements? Because, I want my elements to have meaningful 'id' so that html/jquery code would be easier to read as well as save my time from going through already written jquery code to change those all 'id's that I've used inside.

P.S:drupal version - 6.x

A: 

This problem doesn't really have much to do with the Drupal-FAPI itself, but more with how Drupal theme forms (create the markup).

  • If you want to alter all forms on your site, you can overwrite the theming functions that is used for forms and the different type of form fields.

  • If you just want to overwrite some forms or form fields, you can set the #theme attribute on the form or an element, to change which function should be used for creating the markup.

googletorp
Does it mean I can set my own Id attribute to form elements inside themeing functions? If that's the case, how can I refer to ID attribute of an element? I think I'm kind of lost here.Thanks a bunch.
Andrew
Ok found the solution. I can use attribute key of form element to set any additional attributes(such as class,id..). Thanks for your help so far.
Andrew
+1  A: 

Ok found the solution. I can use attribute key of form element to set any additional attributes(such as class,id..). Thanks for your help so far.

Andrew

related questions