How to Set the Weight of a Submit Handler

The submit handler is used to accept forms submitted by a user. It is executed each time a user attempts to send a form. You can only attach submit handlers to form elements. This will trigger the event handler to accept and send the form to its designated path. You can set the weight by changing the variable in the script to the numerical constant of your choice. Once set, this will be the new weight used by the submit handler.

Instructions

    • 1

      Click "Start" and type "Notepad" into the search field. Double-click the "Notepad" program to open the HTML editor.

    • 2

      Click "File," "New" to create a new file.

    • 3

      Type the following script:

      $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
      '#weight' => 10,
      );
      $form['#submit']['booking_custom_submit'] = array();

      function booking_custom_submit($form_id, $form_values){...}

      Change the weight to the value of your choice.

    • 4

      Click "File," "Save" and name the file. Select ".Html" as the output format. Double-click the HTML file to launch the script.

Related Searches:

References

Comments

Related Ads

Featured