Homec4science

Add a basic multipage form

Authored by epriestley <git@epriestley.com> on May 23 2013, 23:39.

Description

Add a basic multipage form

Summary:
Ref T2232. Very busy day on IRC so I feel like I've made 20 minutes of progress in 1-minute spurts here, but this adds the basics for a form that can have multiple pages and automatically handle pagination and reading to/from the request, objects and responses.

The UIExample is reasonably instructive. Basically, you make a form, add pages to the form, and add controls to the pages. The core flow control looks like this:

if ($request->isFormPost()) {
  $form->readFromRequest($request);                 // (1)
  if ($form->isComplete()) {                        // (2)
    $response = $form->writeToResponse($response);  // (3)
    // Process result here.                         // (4)
  }
} else {
  $form->readFromObject($object);                   // (5)
}

The key parts are:

  1. This reads the form state from the request, including reading all the inactive pages.
  2. This tests if all pages are valid and the user just clicked "Done" on the last page.
  3. This produces a "response", which might be writing to an object (for simpler forms) or creating a transaction record (for more complex forms).
  4. Here, we would save the object or apply the transactions.
  5. When the user views the form for the first time, we preload all the values from some object (which might just be empty).

Ultimate goal here is to fix repository creation to not be a terrible pit of awfulness.

There are probably a lot of rough edges and missing features still, but this seems to not be totally crazy.

I'm using two submit buttons with different names which doesn't work on IE7 or something, but we can JS our way out of that if we need to.

Test Plan: Paged forward and backward through the form.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2232

Differential Revision: https://secure.phabricator.com/D6003

Details

Committed
epriestley <git@epriestley.com>May 23 2013, 23:39
Pushed
aubortJan 31 2017, 17:16
Parents
rPH59946d6433f3: Token - fix fatal for installs with no tokens yet given
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPH40680e459f44: Add a basic multipage form (authored by epriestley <git@epriestley.com>).May 23 2013, 23:39