Closed (fixed)
Project:
Field Group Ajaxified Multipage
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Apr 2013 at 11:19 UTC
Updated:
19 Jan 2016 at 11:52 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
timbrandin commentedBoth problems seem to occur when we used ajax, which totally skips the validate function between the steps and also the submit function on the first step as it seems.
Comment #2
timbrandin commentedBoth problems seem to occur when we used ajax, which totally skips the validate function between the steps and also the submit function on the first step as it seems. I was able to solve the situation by removing the ajax part of the next button.
But I've noticed that the problem also occur or is problematic for the field_groups module, but it does at least not hinder the user from finding the problem and solving it by them self. #1972678: Multipage form validation skipped.
Comment #3
timbrandin commentedHere is a workaround that does not allow for field_group default behaviour when Ajaxify is turned off.
But it does not solve the issue when Ajax is used, it just solved the problem without the ajax turned on.
Comment #4
timbrandin commentedSo that did not work, still need to check so the format is of multipage-group. Here's another try at it.
Comment #5
sinasalek commentedWell the information you're providing is not enough unfortunately
I'm unable to reproduce the issue. And the patch actually disables the module
Comment #6
timbrandin commentedUpdated for beta2.
Comment #7
hypertext200This is also happened to me and none of the above patches helped.
Steps to reproduce:
PHP Fatal error: Cannot unset string offsets in /PATH TO DRUPAL/modules/field/field.default.inc on line 41Comment #8
hypertext200In my case address field was added in to the content type and removing address field and geocoder fields fixed the issue.
Comment #9
hypertext200Closing #2109995: AJAX Errors when trying to validate multipage form as duplicate.
Comment #10
hypertext200I just found this module doesn not work with any custom element, tested with Media Element, File Manages element, Address field element. It looks like the element process function does not invoke when submit the form. Hope this will help to resolve the issue.
Comment #11
katannshaw commentedI can verify that this issue happens for me as well, as noted on my duplicate post noted on #9 (sorry). Here's what happens in my case:
I just installed this module to work with a form I developed using the EntityForm and Field Group modules, so that I could get validation errors on each page of a multipage form. I enabled "Ajaxify" on the form, but unfortunately I received several AJAX errors when I went through the form to test it out.
When I went through the form while completing all required fields, it went through fine. But once I went through the form and purposefully didn't complete required fields to see what would happen, I started receiving this error:
I then went to my error logs at admin/reports/dblog and found these different warnings:
When I disabled "Ajaxify" on the form, it then went through and submitted fine without any of these errors. One thing that I did try was to raise the memory limit on my php.ini file, but that had no effect.
Comment #12
hypertext200I'm having a little bit of luck by adding following lines to the hook_form_alter().. But I need to test a little bit deeper to confirm it, it's great to have another pair of eyes on that.
Other thing I see in this module is this module should use
#access => FALSEinstead of unsetting the field values. I'll work around it to fix it.Comment #13
katannshaw commented@heshan.lk: On which line of the field_group_ajaxified_multipage.module file are you placing those lines of code?
Comment #14
hypertext200I cleaned up a little bit and added rebuilding the node object on validate as well as moved submit callback to the validate since this error occured in the validate. Removed unsetting field elements and added #access to disable it. Seems it works fine and I tried a lot of users cases and those were fine. Tested with Media and Addressfield elements too.
Patch attached.
Comment #15
hypertext200This patch has lot more stuff and rolled up againest the dev branch.
1. Fixed the validation errors
2. Fixed using #access so form values are exists on hook_form_alter.
3. Added scroll top when ajax submit.
4. Lot of bug fixes and clean up.
Comment #16
katannshaw commentedI ended up installing Field Validation module and it's been working fine for me with my multipage entity form.
But I'll still test out this patch on my install to see if it works and I'll report those results soon. Thanks heshan.lk.
Comment #17
hypertext200Thanks, let me know what your findings are so that I can push this to dev.
Comment #18
katannshaw commentedWhen I tried the patch:
I noticed that with an already existing form, when I replaced a required form field's value with something else and click the "Next" button, the validation fires but the form doesn't collect the new value I've entered. It just gets stuck on that step. I have to revert back to the previous version using these setting with this module enabled for it to work properly again:
Non Javascript Multistep = Yes
Ajaxify = No
Comment #19
hypertext200@jayhawkfan75, this patch is against the dev branch. Did you get any hunks those are rejected.
Comment #20
katannshaw commented@heshan.lk: Sorry about that. The patch worked *great* against the dev branch. I'll definitely be using this module. I like the smooth transition from page to page. Nice touch.
One thing that I would note that got mentioned on this issue report for the Field Group module is that it may make more logical sense for some developers and users alike if the "Next step | Previous step" buttons were switched in order to "Previous step | Next step".
I'm still a newbie, so I don't know how to do patches as of yet. However I was able to accomplish this by switching the buttons placement on Line 323 of field_group_ajaxified_multipage.module:
to this:
...just in-case anyone's interested in this change. Thanks so much for your help with this heshan.lk!
UPDATE:
Another couple of issues that I just noticed with the dev version is...
Before applying the patch on the dev version, the validation fires for checkbox fields on other pages of my multipage form, so I cannot move to the next step. The data in the form fields also disappears when the validation fires.
After applying the patch, that validation issue is still there, but the data stays in the form fields as it should.
Reverting back to 7.x-1.0-beta2 made those bugs go away. If you need for me to test things further against my install, let me know. Sorry.
Comment #21
hypertext200Thanks for reviewing the patch. Do this, after applying the patch change line 596 to below. Remove the #access = FALSE
Comment #22
katannshaw commentedYou're welcome heshan.lk. I gave it a try, and this is what happened with different settings for the multipage field:
Attempt #1:
Move additional settings to last multipage (if available): No
Non Javascript Multistep: No
Ajaxify: Yes
- Went through pages of form without a problem, but didn't collect any of the entered data.
Attempt #2:
Move additional settings to last multipage (if available): Yes
Non Javascript Multistep: No
Ajaxify: Yes
- When validation fires, entered data disappears from form fields.
Attempt #3:
Move additional settings to last multipage (if available): No
Non Javascript Multistep: Yes
Ajaxify: Yes
- Went through pages of form without a problem, but didn't collect any of the entered data.
Attempt #4:
Move additional settings to last multipage (if available): Yes
Non Javascript Multistep: Yes
Ajaxify: Yes
- When validation fires, entered data disappears from form fields.
- Won't move past step 1 because checkbox validation keeps firing even when it's checked.
When I changed Ajaxify > "No", it still didn't work properly, so I reverted back to the beta version. If there's another way that you'd like me to test the settings or anything else, please let me know. I appreciate your working on this.
Comment #23
hypertext200Thanks for the feedback and the test cases. Additional settings is a strange issue and looks like some other module (field_group) take control over it so we don't get access to change it. I'll digg more deep in to this and see if I could find a solution. Thanks.
Comment #24
katannshaw commentedVery good. Thank *you*.
Comment #25
hypertext200@jayhawkfan75, I was looking at much deeper in to the issue and found out that we don't need to rework on additional settings in this module, so after patch commented out the from "Remove non grouped fields in all other steps except the first one" to it's end. Because this should normally handle by a
#prerenderhandler and field_group it self has that facility, and we can't just unset additional settings like we do in this module, we must move them to the related group.So to be clear follow following steps.
Then test. Looks like it fixed the all the issue we are having, that for the previous test it helps a lot to get me here.
Comment #26
8bitplateau commentedWith the patch from #15 the added function "_field_group_ajaxified_multipage_field_unset" causes errors with required fields, or at least required booleans ( this is all i've tested )
In my case I had two steps, each with a required boolean.
Pressing next on step one causes the whole form to validate, this obviously shows form errors for both booleans, but you are still stuck on step one and cant get to step two to check the boolean.
This is because the form item attribute "#access" applied to the group children in the function does not play well with #required ie the item is still required just not rendered in the form.
I removed _field_group_ajaxified_multipage_field_unset entirely and in its place wrote
in the loop
in field_group_ajaxified_multipage_form_alter() function
it basically makes sure and required fields in future steps are NOT required, then hides the group, and simply hides the group in all past steps.
Comment #27
thijsvdanker commentedI had validation errors and used the patch in #15 with the comment in #25 (commenting out some lines), and validation works!
To reproduce the bug I was experiencing: add a file field to one of your steps, and that step and all following steps will only validate once.
The attached patch is #15 applied against the master branch!! (as that branch contained 2 extra commits in comparison to 7.x-1.x) with the lines commented out as per #25.
Please review, proper validation is kind of critical I suppose.
ps: @digitisation (#26) I could not reproduce your problems with the boolean with this patch.
Comment #28
sinasalek commentedThanks, i'll commit this if someone else confirm that it solves the problem
Comment #29
thijsvdanker commentedI've changed the validate function to check for other entity types then just node.
@sinasalek, thanks. against what branch would you like to have a patch? Any good reason why master and 7.x-1.x have diverged?
Comment #30
thijsvdanker commentedAnd changed the code comment to reflect the change.
Comment #31
iniKim commented@thijsvdanker: I reviewed your latest patch (https://www.drupal.org/node/1972616#comment-9506279) and everything works fine! Thanks Thijs!
Comment #32
hydra commentedThe patch in #30 worked for me on the master branch. Not sure how this is handled in this module, but normaly there should be no master branch and 7.x-1.x should contain the newest codebase.
Manual testing only in UI mode showed me, that this works, thx for fixing it!
A quick code review was showing tons of wrong code formatting. Also there are some bad comments and code which is not used anymore. I guess this should be clean upped before commiting. More infos about coding standards in drupal can be found here https://www.drupal.org/coding-standards
Below just some examples.
Not sure if this code formatting stuff belongs to this issue
This can be removed completly
Inline comments are bad style
This also looks like it could be removed
This is no comment
Comment #33
sgurlt commentedI tried it now with the dev and the 1.0 beta 2 version but in both cases after applying the patch the form is submitted, but all values are lost. I am currently working on this
Comment #34
sgurlt commentedI rerolled the patch #30. During it I had to refactor some code to get the submit running again.
In addition I adjusted as much code as possible to meet the drupal coding guidelines.
The patch is based on the version 7.x-1.0-beta2, I could not get it running with the latest dev version.
Comment #35
sgurlt commentedMissed one thing ...
Comment #36
sgurlt commentedAnd another reroll of that patch as the posted patch resultet in undefined indexes when placing groups in groups.
Comment #37
sgurlt commentedJust saw 3 minutes to late why the unset is at the bottom of the module file.
Instead of unsetting (which results in undefinied indexes, I hide the field groups which are not in the current steps.)
Comment #38
m.attar commentedHi,
The solution you suggested provide problem if I try to save|update a node on click Next button using custom validate handler.
The problem that the node updated inside the handler validate, but if i reload the form I noticed nothing updated,
for details you can see my code below:
If i refreshed the form and tried to load the node(on the hook_form_alter()) I noticed that the node doesn't updated,
the data that saved by handler company_node_form_save() gone doesn't appear.
Can anybody help me out with this, or give me a way(handler) to update a node.
Thanks
Comment #39
sgurlt commentedHey,
I think what are you looking for is not related to that issue. You should open a new one.
I will have a look at it tomorrow.
Greetings
Comment #40
m.attar commentedThank you @sg88,
Before I applied your solution it was work properly.
I was used the handler submit for button Next to add my handler(company_node_form_save), explained in the following code:
And it work properly, but when I applied your solution I wont be able to use this handler, in addition if I add the handler submit for button Next still not working.
Thank you
Comment #41
sgurlt commentedHm very strange, could you please try to use it with patch #30.
I just refactored it to meet the drupal coding standards and did some bug fixes inside it.
Comment #42
7thkey commentedsg88 patch #37 works for me, getting rid of this nasty fatal errors
Comment #43
m.attar commented@sg88 Ok thank you
Comment #44
sgurlt commentedThanks for the feedback, could you please adjust the issue status to tested? :)
Comment #45
m.attar commented@sg88 you should remove the following code from your last patch(#37) because you repeated:
Thanks
Comment #46
sgurlt commentedAlright, thanks for the hint, during removing the code duplication, I removed even more "bad" code.
Please have a look on it again.
@attar_eweev: I just rechecked your posting, could you please try to get your values for your node save form $form_state['storage']['all'] and try again.
Comment #47
m.attar commented@sg88 it work properly.
Comment #49
sgurlt commentedComment #50
sgurlt commentedFixed a lot of stuff in the latest commits.
Dev branch is now up to date again.