Skip to content

Drupal Forms API

2009 June 29
Posted by bharatsharma83@gmail.com

This post is about the Form API of drupal6, You may find this post written in a little bit of unimpressive way, this is bcoz i am running short of time these days nonetheless i would like your suggestions and comments at any time and will try to make them happening:

Forms API

  • The forms API abstracts forms into a nested array of properties and values.
  • $form_values is array which holds form elements values.
  • The form token (form unique id) is stored in the variables table as drupal_private_key.
  • drupal_get_form() function interact with drupal form.
  • hook_elements() function is used to define element type.
  • hook_element() can be used to define your own element types in your module.
  • element_info() hook collects all the properties for all form elements.

FORM PROPERTIES

  • #validate property is used to validate the form elements.
  • #base is used to apply same validator to several forms.
  • #submit handles form submission. If there is no property named #submit, drupal looks for function name “formID_submit()” or failing that drupal again search for “#basevalue_submit”.
  • #after_build property will call all functions of a form.
  • #theme is used to set a theme to an existing form.
  • #pre_render property used to call the functions just before the transformation of form from a data structure to HTML.
  • #prepend, #suffix properties are used to prepend and append text to  the form elements. drupal also uses these properties while rendering the form.
  • #method property is used to set the form method to post. By default it is set to post, Also get method is not supported by the form API.
  • #tree : Setting #tree to TRUE gives a nested array of fields with there values. While #tree is set to FALSE, we get a flattened representation of field name and values.

FLOW of form formation:

when a module contains a form code is called by drupal the form datastructure renders form into html in the following sequence:

call drupal_get_form() -> call hook_elements()['defining element types such as radio buttons, chekcboxes, textfiels'] -> call elements_info() [information about the related properties ,values and functions] -> #validate property -> #submit property

Bibliography: Apress Pro Drupal Devlopement (ycu73k6ath)

50 Responses
  1. June 30, 2009

    I guess i really wanted to thank you for giving us an idea regarding drupal theme it let us easy to understand the use of it.

  2. bharatsharma83@gmail.com permalink
    July 2, 2009

    Thanks cmsthemer

  3. September 15, 2009

    great post.

  4. April 23, 2010

    Super-Duper website! I am loving it!! Will come back again – taking you feeds also, Thanks.

  5. April 26, 2010

    There’s good info here. I did a search on Google, Keep up the good work mate!

  6. May 18, 2010

    Hello,this is Astrid Prentis,just discovered your Blog on google and i must say this blog is great.may I share some of the Post found in the post to my local buddies?i’m not sure and what you think?in either case,Thx!

  7. May 19, 2010

    This is a great post, I stumbled across your article while looking for some information on SQL. Thanks for sharing, I’ll be sure to come back.

  8. May 28, 2010

    Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

  9. bharatsharma83@gmail.com permalink
    May 31, 2010

    Thanks you can share this my pleasure

  10. bharatsharma83@gmail.com permalink
    May 31, 2010

    Thanks dude

  11. bharatsharma83@gmail.com permalink
    May 31, 2010

    Cool Thanks

  12. bharatsharma83@gmail.com permalink
    May 31, 2010

    Thanks Will try my best on SQL.

  13. June 17, 2010

    Wow love this blog, looks particularly good in safari for some reason!

  14. June 19, 2010

    Wow! Thank you! I often wanted to write in my web site something like in which. Can I take a part of your post to my weblog?

  15. June 20, 2010

    Great insights. I loved reading this article.

  16. June 21, 2010

    I want to thank you for the endeavors you have made in publishing this article. I am trusting the same best work from you in the future as well

  17. June 23, 2010

    So helpful it seems to me, my luck to read your blog, thank you.

  18. June 23, 2010

    I have got start reading ability including possible types concerning weblogblog site your used jewelry,as well as the i was gday in order to really regularly maintain most blogdog owners words and phrases investigate desire being worthless tutorials,although your own house are generally actually, we not unlike make certain your amazing blog page,as well as a method fully feel fortunate moreover will probably find out things creative,and additionally explain to respect their this page when

  19. June 23, 2010

    Your blog is so informative ¡­ keep up the good work!!!!

  20. June 25, 2010

    赞一个 文章写的挺好 支持一下

  21. June 28, 2010

    Thank you so much for so interesting article. Good job!

  22. June 30, 2010

    Greetings! Our staff members are wanting for potential internet writers, would likely you be interested? This method probably will not render you way too rich nonetheless there is an intriguing comp and if you rather love posting then this one opportunity is for you.

  23. June 30, 2010

    I’ve been actually searching for related info. Im lucky I ended up here. Thank you

  24. June 30, 2010

    yes i am interested

  25. July 1, 2010

    Nice list. Definite bookmark!

  26. July 4, 2010

    Thank you for the captivating article, can I ask where you get your information from?

  27. July 16, 2010

    Nice site and great text.

  28. July 16, 2010

    I can’t but agree.I always wanted to write in my site something like that but I guess you’r faster.

  29. July 18, 2010

    Hi buddy, your blog’s design is simple and clean and i like it. Your blog posts are superb. Please keep them coming. Greets!!!

  30. July 19, 2010

    hey there I just wanted to comment your blog and say that I really enjoyed reading your blog post here. It was very informative and I also digg the way you write! Keep it up and I’ll be back to read more soon mate

  31. July 23, 2010

    You got a really useful blog I have been here reading for about half an hour. I am a newbie and your post is valuable for me.

  32. July 26, 2010

    Nice posts here.. danke for writing so much in your blog.. Greets, kesselgulasch gartenparty

  33. July 28, 2010

    Super text, I will add this blog to my favorites.

  34. July 29, 2010

    I am happy to find so many useful information here in the post, we need develop more strategies in this regard, thanks for sharing. . . . . .

  35. July 30, 2010

    interesting post, pretty much covered it all for me, bookmarked.

  36. July 31, 2010

    Really great informative blog post here and I just wanted to comment & thank you for posting this. I’ve bookmarked youi blog and I’ll be back to read more in the future my friend! Also nice colors on the layout, it’s really easy on the eyes.

  37. July 31, 2010

    I’ve read some good stuff here. Definitely worth bookmarking for revisiting.

  38. August 4, 2010

    Cool stuff, thanks for sharing, pretty much on the ball.

  39. August 5, 2010

    Book-marked your website. Thank you for discussing. Definitely worthy of the time far from my tests.

  40. August 5, 2010

    I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success.

  41. August 6, 2010

    Idol, great writing, too talented …

  42. August 7, 2010

    Hi. Just did some internet searching and discovered this website. I went through this weblog post and it’s really amazing. I bookmarked it and i am looking forward to your upcoming weblog posts. I also see that your blog has some good linking done to it. I was thinking if you’d like to share your secrets on how to obtain that pr. Anyhow great read again. Amazing info you got here.

  43. August 9, 2010

    Because it is the 1st visit to your webblog, I wanted to say hello there! Wonderful blog incidentally.

  44. August 11, 2010

    Hei, I like this blog, many good information, I want to subscribe it, can anyone help me?

  45. August 15, 2010

    Thanks for good article. Hope to see more soon.

  46. August 15, 2010

    Can you email me back, please. Thank you.

  47. August 15, 2010

    Good post, keep it up!

  48. August 16, 2010

    really nice article. i hope to implement some of these in my blog. thank you!

  49. August 16, 2010

    I agree with the author that we need to share the knowledge we gain!. . . . . .

Trackbacks and Pingbacks

  1. Drupal Forms API | bharat sharma | Neorack Script

Comments are closed.