Completing the update page block by block (ColdFusion)
An update page has three building blocks:
- A filtered recordset to retrieve the record from a database table (see Retrieving the record to update (ColdFusion))
- An HTML form to let users modify the records data
- An Update Record server behavior to update the database table
You can add the final two basic building blocks of an update page separately using the form tools and the Server Behaviors panel.
Before you can add the building blocks, your web application must be able to identify the record to update, and your update page must be able to retrieve it. See Searching for the record to update (ColdFusion), Creating the links to open the update page (ColdFusion), Creating a URL parameter for update links (ColdFusion) and Retrieving the record to update (ColdFusion).
Completing the update page consists of three tasks:
- Adding an HTML form to the page to let users modify the data
- Displaying the record in the form by binding the form objects to database table columns
- Adding the Update Record server behavior to update the database table after the user modifies the record
To add an HTML form to an update page:
- Create a new Coldfusion page (File > New).
- Lay out your page using the Dreamweaver design tools.
- Add an HTML form by placing the insertion point where you want the form to appear and selecting Insert > Form > Form.
An empty form is created on the page. You may have to enable Invisible Elements (View > Visual Aids > Invisible Elements) to see the forms boundaries, which are represented by thin red lines.
- Name the HTML form by clicking the
<form> tag at the bottom of the Document window to select the form, opening the Property inspector (Window > Properties), and entering a name in the Form Name text box.
You dont have to specify an
method attribute for the form to tell it where and how to send the record data when the user clicks the Submit button. The Update Record server behavior sets these attributes for you.
- Add a form object such as a text field (Insert > Form > Text Field) for each column you want to update in the database table.
The form objects are for data entry. Text fields are common for this purpose, but you can also use menus, checkboxes, and radio buttons.
Each form object should have a corresponding column in the recordset you defined earlier. The only exception is the unique key column, which should have no corresponding form object.
For more information on form objects, see Inserting HTML form objects.
- Add a Submit button to the form (Insert > Form > Button).
You can change the label of the Submit button by selecting the button, opening the Property inspector (Window > Properties), and entering a new value in the Label text box.
To display the record in the form:
- Make sure you defined a recordset to hold the record the user wants to update.
For more information, see Retrieving the record to update (ColdFusion).
- Bind each form object to data in the recordset, as described in the following sections:
- Displaying dynamic content in HTML text fields
- Dynamically preselecting HTML checkboxes
- Dynamically preselecting HTML radio buttons
- Creating a dynamic HTML form menu
- Making existing HTML form menus dynamic
To add a server behavior to update the database table:
- In the Server Behaviors panel (Window > Server Behaviors), click the Plus (+) button and select Update Record from the pop-up menu.
The Update Record dialog box appears.
- Complete the dialog box.
For instructions, see Setting the Update Record dialog box options (ColdFusion).
- Click OK.
Dreamweaver adds a server behavior to the page that lets users update records in a database by clicking the Submit button on the form.
To edit the server behavior, open the Server Behaviors panel (Window > Server Behaviors) and double-click the Update Record behavior.
- Completing the update page in one operation (ColdFusion)