Book Image

Learning Joomla! 1.5 Extension Development

Book Image

Learning Joomla! 1.5 Extension Development

Overview of this book

Table of Contents (17 chapters)
Learning Joomla! 1.5 Extension Development
Credits
About the Author
About the Reviewer
Preface

Requiring specific fields


When the restaurant critics are entering reviews into the system, there are a few fields on the form in the single view that they should always complete. As a minimum, we have decided that each review needs a Name, Address, and a Quicktake. Without these fields, a review is effectively useless. To enforce these requirements, we need to add some JavaScript that will intercept the events when the Save and Apply buttons are clicked, and check that these fields have been specified.

The JavaScript that we will add should test the value of each required field, then throw an alert and stop the form from submitting when any one of them is blank. The backend of Joomla! is configured so that whenever one of the toolbar buttons is clicked, it attempts to execute the submitbutton() JavaScript function (if one exists). Let's add one of these functions to the top of the single view. Go to /administrator/components/com_restaurants/views/single/tmpl/default.php and add the highlighted...