Create the employee editing form

In this section of the tutorial you will build the NeXTensio form which allows manipulating employee data: adding, editing and deleting.

The page will be created in two major steps:

  1. Add the NeXTensio form. The NeXTensio form will be based on the database table explained at the beginning of this tutorial, containing the name and salary fields.

  2. After you add the NeXTensio form, you will have to manually add a field that will allow uploading the photo. Uploaded file names will not be stored in the database. Instead, files will be renamed using a rule.

Add the NeXTensio form

The first step is to add the NeXTensio form to the page. To do so, follow the next steps:

  1. Open the form page in Dreamweaver.

  2. Apply the Create NeXTensio Form Wizard from the MX Kollection tab of the Insert panel. Configure each step of the wizard as follows (most options should be already set if you haven't disabled the user interface persistence):

Add photo uploading capability

To allow the upload of a photo for each employee, you need to add to the NeXTensio form a new form field. You also have to add the logic that uploads the image files to the server. To do so, follow the next steps:

  1. Place the mouse cursor in the Salary table cell. Right click in the cell, and from the pop-up menu select Table > Insert Rows or Columns. Add one row, below the current selection.

  2. The new row will have two columns: In the first one, enter the label (Photo), and in the second, add a form file field (from the Forms tab of the Insert panel).


     

  3. Now, the form should look like:


     

  4. The NeXTensio form allows adding or updating multiple records at once, in a single operation. This means that you can add more than one employee to the database, and this is possible because the name and salary fields contain, for both the name and ID, a static name and a dynamic value.
    For example, the name field has the following name attribute:

  5. The cnt1 variable increments for each new record that is added, allowing each field to have a unique name. This way, information is added correctly into the database. You will have to add the same code bit for both the file field name and ID. The file field element code will have to look like this:

  6. The HTML elements are now in place. This means you have to start adding application logic. This is composed by two actions:

  7. First add the image upload logic. Apply the Upload and Resize Image server behavior from the Server Behaviors tab > + > MX Kollection > File Upload, and configure it as follows:

  8. Next you need to add the component which will remove a photo from disk when an employee is removed from the database. This will be implemented with the Delete File server behavior. You can access this server behavior from the Server Behaviors tab > + >MX Kollection > File Upload. Configure the user interface that opens as follows:

The form page is now complete, and you can save it. After uploading it to the server, you can test it in the browser, by clicking on the Add new link/button in the list. Fill in the required information, and select a file from the local disk to upload. It will be renamed according to the defined rule.