I've been trying to create custom elements (in D7) and want to know if anyone has some 'best practices' advice for me. I'm not using the Field API because I want to interact with data outside of Drupal. So, on to my questions:

  1. Where should I define my form elements?
    My custom element will be made of textfields, radios, checkboxes, and selects. Should these sub-elements be added in the hook_element_info(), or in my #process callback?
  2. If I'm processing with AJAX, where does that go?
    I've worked through the examples included with the D7 Example module, but I'm not clear on how AJAX interacts with custom elements (all the elements work with basic field types like checkboxes and textfields).
  3. A custom element should be re-usable: how does this affect forms
    When I finally get my element working, I'd like to to re-use it in node forms and anywhere else it might be useful. Will I have to write processing code for each use-case? Is that what the #process callback is for?

Drupal makes my headspin. I built a personal website with D6, but never did any module development with it. Any tips will be helpful.

Comments

JohnWoltman’s picture

If I get all of this working, I will gladly write a tutorial on making custom elements. The D6 tutorial needs to be updated for D7 anyway. Right now I'm mostly stuck on #1 above.