Using an Application Object

If you want to create an update page with a form in one step rather than using the method described in the previous section, you can use the Record Update Form Wizard application object. This application object inserts an HTML form, adds dynamic text fields to the form fields, and adds the Update Record server behavior.

The application object doesn't create a master page for selecting a record, so you'll still need to create this beforehand if you haven't already (see "Building a Master Page for Selecting a Record," earlier in this chapter). You'll also need to define a filtered recordset beforehand (see "To create an update page and a filtered recordset" in the preceding section).

While you have more options for customizing the dynamic form if you create the update page manually, using the application object will save you a little more time (the amount of time it takes to create a dynamic form).

To update a record using an application object:


Open the select.php page. Save it as select2.php.


On the page, select the link in the dynamic table, and change the page name in the link to update_oneStep.php (Figure 12.37). Change only the link name, not the URL parameter code at the end of the link name. Save the page.

Figure 12.37. Use the Link field in the Property inspector to change the name of the linked page.

This is the master page for this task. It is exactly the same as the previous master page except that the link name is changed.


Create a new update page by redoing the exercise, "To create an update page and a filtered recordset," in the previous section of this chapter. Save the new update page as update_oneStep.php.

You need to create a new update page rather than re-saving the old update.php page you created earlier in this chapter because the old update.php page contains a form and an Update Record server behavior that we don't want included in the new page.


From the main Dreamweaver menu, choose Insert > Application Objects > Update Record > Record Update Form Wizard (Figure 12.38).

Figure 12.38. Use the Insert menu to add the Record Update Form Wizard application object to your update page.


The Record Update Form dialog appears. This dialog is very similar to the Update Record dialog we used in the previous section of this chapter.


From the Connection drop-down list, select the name for your connection to the travelclub database (Figure 12.39). Our connection is named connTravelClub. From the Table to Update drop-down list, select the members table. From the Select Record From drop-down list, select the name of the filtered recordset you created in Step 1. We named our recordset update.

Figure 12.39. Choose the id field and any other fields to update in the Record Update Form dialog.


From the Unique Key Column drop-down list, select the id field. Check the Numeric box, since the id key is a five-digit number. In the After Updating, Go To field, enter the name of the confirmation page you created in the last task in the preceding section, confirmation_email.php.

You're using the primary key field (id) to identify the unique record to update in the database. The confirmation page is the same as in the preceding taskthe function of this page is to let the user know that his or her information has been submitted. You can use the same confirmation page with more than one update page.


In the Form Fields section, select the id field from the list. In the Label field, type a label to display on the update page for this field. From the Display As dropdown list, select Text. The Submit As drop-down list is dimmed in this case because we already specified that this was a numeric field in Step 7.


Select the email field from the list. Repeat Step 8 for this field, but from the Submit As drop-down list, select Text.

If you don't want to include the other two fields (first_name and last_name) in your update page, select each field name and click the minus button to delete the field from the form on the update page.

In either case, the PHP code for the dynamic form field is displayed in the Text field at the bottom of the dialog, and is automatically inserted into your page.

If you don't want a particular field to be dynamically populated with the current value in the database when the page is sent to a browser, select the field in the Form Fields section, and then select and delete the code in the Text field.


Click OK to close the dialog and insert the application object. Save the page. Now we need to test the page in a browser.


Open the select2.php page in Dreamweaver and choose File > Preview in Browser.


Click a link for a record to update (Figure 12.34), and then enter a new e-mail address on the update page (Figure 12.40).

Figure 12.40. Use the update page to update a name or e-mail address, and click the Update Record button to submit the changes to the server.

The confirmation page appears (Figure 12.36).

Macromedia Dreamweaver 8 Advanced for Windows and Macintosh. Visual Quickpro Guide
Macromedia Dreamweaver 8 Advanced for Windows and Macintosh: Visual QuickPro Guide
ISBN: 0321384024
EAN: 2147483647
Year: 2004
Pages: 129
Authors: Lucinda Dykes

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: