Home arrow Design Usability arrow Page 9 - Using HTML_QuickForm To Manage Web Forms, Part 1
DESIGN USABILITY

Using HTML_QuickForm To Manage Web Forms, Part 1


Tired of authoring dull and dreary Web forms everyday? Fed up of programming JavaScript validations day-in and day-out? Then, the HTML_QuickForm package is just the solution for which you are looking. In the first part of this two-part tutorial, I'll get you started with the basics of building Web forms using this resourceful PEAR package.

Author Info:
By: Harish Kamath
Rating: 5 stars5 stars5 stars5 stars5 stars / 73
December 22, 2004
TABLE OF CONTENTS:
  1. · Using HTML_QuickForm To Manage Web Forms, Part 1
  2. · Installing The HTML_QuickForm Package
  3. · My First HTML_QuickForm
  4. · FORM Elements
  5. · Adding Standard HMTL FORM Elements
  6. · Defining FORM Controls, Submitting Data
  7. · Grouping
  8. · "Checkbox" and "Radio" Elements
  9. · Drop Down Control and Hidden Element
  10. · Implementing Form Validations
  11. · Password Field Validation
  12. · Processing Data With HTML_QuickForm
  13. · Conclusion

print this article
SEARCH DEVARTICLES

Using HTML_QuickForm To Manage Web Forms, Part 1 - Drop Down Control and Hidden Element
(Page 9 of 13 )

<?php

// snip

// create a multiple select drop down
$obj_registration_form->addElement('select', 'ddlLookingFor', 'Looking For:', array ("Publishing_Deal" => "Publishing Deal", "Label_Deal" => "Label Deal","Management_Deal" => "Management Deal", "Other" => "Other"), array("size" => "3", "multiple"));

// snip

// add a hidden value
$obj_registration_form->addElement('hidden', 'txtReferrer', 'http://www.mysite.com');

// snip

?>

Next, I have added a multiple <SELECT> drop down control. This is pretty straightforward - just pass a value for the "size" attribute and the "multiple" keyword as elements of the array to the addElement() method.

This is followed by the definition of a "hidden" element - for the sake of completeness.


<?php

// snip

// creates a group of buttons to be displayed at the bottom of the form
$obj_submit[] = &HTML_QuickForm::createElement('submit', 'btnSubmit', 'Register');
$obj_submit[] = &HTML_QuickForm::createElement('reset', 'btnReset', 'Start Again');
$obj_registration_form->addGroup($obj_submit, '', '', '&nbsp;&nbsp');

// snip

?>

Above, I have grouped the two "button" controls in order to display them on a single line - once again using the ubiquitous "grouping" concept.

So far, I have manually added the different elements to a "group." However, the HTML_QuickForm() object also supports some controls that are "grouped" internally. The custom "date" element is one such example. This element is rendered by three drop down controls: one each for the day, month and year fields. The following statement will render an instance of the "date" element in a Web form:

<?php

// snip

$obj_registration_form->addElement('date', 'txtDateOfBirth', 'Date of Birth:');

// snip
?>

That was pretty simple, wasn't it?

Now, what’s next? Form validations, which is one concern that has yet to be addressed by the HTML_QuickForm() object. Not for long though,  as you shall soon see in the following section.


blog comments powered by Disqus
DESIGN USABILITY ARTICLES

- Responsive Web Design: More Than Just a Buzz...
- Add New Website Features to Please Users
- Gzip Components in Action
- Configuring Gzip Components
- Gzip Components
- Create Great JavaScript and CSS Menus Simply
- Design Principles that Shape a Web Site
- Creating Aqua Style Images
- Easy as A,B,C – dynamic A to Z indexes
- EasyChart: a Usability Teaching Tool to Demo...
- Building Friendly Pop-up Windows
- Back to School: Design Usability
- Using HTML_QuickForm To Manage Web Forms, Pa...
- Using HTML_QuickForm To Manage Web Forms, Pa...
- More Website Knick Knack

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials