Example: AJAX Graceful Degradation

  1. drupal
    1. 8
    2. 7

These examples show AJAX with graceful degradation when Javascript is not available.

In each of these the key idea is that the form is rebuilt different ways depending on form input. In order to accomplish that, the formbuilder function is in charge of almost all logic.

Functions & methods

NameDescription
ajax_example_add_moreThis example shows a button to "add more" - add another textfield, and the corresponding "remove" button.
ajax_example_add_more_add_oneSubmit handler for the "add-one-more" button.
ajax_example_add_more_callbackCallback for both ajax-enabled buttons.
ajax_example_add_more_remove_oneSubmit handler for the "remove one" button.
ajax_example_add_more_submitFinal submit handler.
ajax_example_dependent_dropdown_degradesA form with a dropdown whose options are dependent on a choice made in a previous dropdown.
ajax_example_dependent_dropdown_degrades_first_callbackSelects just the second dropdown to be returned for re-rendering.
ajax_example_dependent_dropdown_degrades_submitSubmit function for ajax_example_dependent_dropdown_degrades().
ajax_example_dynamic_sectionsExample of a form with portions dynamically enabled or disabled, but with graceful degradation in the case of no javascript.
ajax_example_dynamic_sections_select_callbackCallback for the select element.
ajax_example_dynamic_sections_submitSubmit function for ajax_example_dynamic_sections().
ajax_example_dynamic_sections_validateValidation function for ajax_example_dynamic_sections().
ajax_example_wizardThis example is a classic wizard, where a different and sequential form is presented on each step of the form.
ajax_example_wizard_callback
ajax_example_wizard_submitSubmit function for ajax_example_wizard.

examples/ajax_example/ajax_example_graceful_degradation.inc, line 8