There are three basic ways in which forms are used in a user interface:
To input data for a separate action—say, Google search
To create new data
To change existing data
It's the last option is what we are interested in now. To accomplish this, we need to learn how to load that data from its source (static or database) into our user interface—our form.
We can take data from somewhere in our code, a variable for instance, or just plain static text, and display it as the value in our form field by calling the setValue
method. This single line of code will set a field's value:
movie_form.getForm().findField('title'). setValue('Dumb & Dumber');
Once we start working with larger forms with many fields, this method becomes a hassle. That's why we also have the ability to load our data in bulk via an AJAX request. The server side would work much as it did when we loaded the combo box:
<?php // connection to database goes here $result = mysql_query('SELECT...