During working on the profile2 module I added registration integration, however once a field with "add-more" functionality is added and 'add-more' button appears. This button falls back on a multistep form once there is no JS, however as the form initially is no multistep form - it looses it's form values.
Thus it's impossible to cleanly add fields to the registration form that way.
Possible fixes would be
1) the new form-value keeping method suggested in #622922: User input keeping during multistep forms
2) using a clean form workflow that's working regardless the form is going through multiple steps or not. For the discussion regarding the right workflow see: http://drupal.org/node/367006#comment-2272166
Personally I favour 2) as I think 1) would introduce possible troubles with real multistep forms (see issue).
If we make storage more straight forward to use (-> #367006: [meta] Field attach API integration for entity forms is ungrokable) we could easily move the data (-> $user) to the storage by default. Then everything would stay working regardless the form workflow involves multiple steps or not.
Note:
* This problem is in d6 too. While fixing this probably involves too much changes for d6, we should really fix it for d7 right now.
* This problem probably affects most of drupal's forms as usually they are not prepared to work with multiple steps. Thus altering it to do so won't work.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | form_multiple.patch | 3.64 KB | fago |
| #9 | form_multiple.test | 3.64 KB | fago |
Comments
Comment #1
fagoehm, linked the wrong issue for making storage more straight forward -> #634440: Remove auto-rebuilding magic for $form_state['storage']
Comment #2
effulgentsia commentedI'd like to understand 2) more, and am open to it if it allows form construction/alter/process/validate/submit functions to be written in a straightforward way. But I disagree that 1) would introduce problems with multistep forms. There's already a patch on that issue (#65) that works correctly, and ongoing refinements to it would need to also work with multistep forms before the issue is ready for commit.
Comment #3
sunComment #4
fagoLet's discuss that in the issue over there -> I've responded there.
Comment #5
fagoops, cross post.
Comment #6
sun.
Comment #7
fago#622922: User input keeping during multistep forms landed. I just gave this a test again and it still doesn't work. This is due to the field API, which still forces the form to have an own persistence mode:
Comment #8
sunI suggest to add a hook_form_alter() implementation to form_test module for the user registration form (which is a nice prototype of a non-multistep form) that adds a multiple value field to the form, and add a test that ensures proper form processing and rebuilding for the altered form.
The patch in #370537-78: Allow suppress of form errors (hack to make "more" buttons work properly) contains some nice fake multiple value field widget code, which we can copy + paste into a form_alter. If this test fails, then this issue needs to be bumped to critical.
Comment #9
fagoWell the problem doesn't appear with regular rebuilds as long as they don't scratch the input values by setting
$form_state['input'] = array();Thus I implemented a test case, that shows it's working with a basic rebuild, but it fails when using the field API. Because the field API demands the form to have its own multistep persistence as I noted in #7, letting the use case of profile2 (registration integration) fail.
Setting to "needs review" to let the test bot run.
Comment #10
fagoComment #11
fagoComment #13
sunAs this bug seems to break and prevent evolution of a new Profile module, bumping to critical.
Comment #14
fagosee #735808: fix multiple field value form to work with form API persistence
Comment #15
effulgentsia commentedPlease add the failing test from #10 to #735808: fix multiple field value form to work with form API persistence and I think we're golden.
Comment #16
gisleRenaming non-canonical duplicate tag. See #2426171: Multiple tags similar to 'API clean-up' for background.