Picklist loses values on validation failure

achartier

Administrator
Staff member
This issue may be similar to this one: fabrikar.com/forums/index.php?threads/urgent-big-problem-with-picklist.35948/

I have a picklist with a php validation. I check to see if the addition to a picklist is a duplicate of one that is already there. If so I post a message via $this->setMessage. When the form returns from validation the message displays correctly and the default error "Some parts of your form...." is presented. However, all the values that were in the To column have been returned to the From column. This is true for values that came from the database (i.e. which where present when the form first loaded) as well as the additions.

Clearly not an expected behavior.

Site access via my Mexico test site in my sites. Got to menu Member Resources->My Profile. You are not viewing a Community Builder profile. Click on the Hover over Edit and then click on Update your profile. At the bottom you will see a disabled textarea called Interests. To the right of that is a link called "Click to Update". This link will open a modal dialog with the form (#30). The only element on the form is the picklist. I have added a number of items to the picklist so it should show up with items on both sides.

Click on the + button to add a new element and enter a value which already exists, click Add and then Save. You will see the behavior. You can also see what happens when you add a valid entry, it works fine. It is only on validation failure the problem shows up.

Hope one of the experts here can help. Thanks.
 
Thanks Hugh, I can confirm that this commit fixes the problem.

No doubt I will at some point take out another sub.
 
Well, perhaps I spoke too soon. On further testing it appears the addition is still in the data list for the control. When I add a new value and the validation fails, the picklist is redrawn correctly showing the original state before any addition. However, the hidden inputbox that contains the values still has the addition in it so if the form is then saved the addition is saved to the database.

Also you may notice that the To list shows a small area at the bottom under the last displayed item. I think this may be leftover somehow when the control is redrawn.
 
Hi Hugh, I imagine this is relatively straightforward to correct. It is the only thing holding me up from publishing this project. Friendly bump, hopefully you will get a chance to peek into the issue.

Thanks.
 
Hmmm, I guess my response was too subtle?

No doubt I will at some point take out another sub.

No doubt at some point I'll take a look.

But I'll go and have another look now, just because I'm a nice guy, and you've been a good customer. Although I am a nice guy that needs to go to the grocery store occasionally. ;)

-- hugh
 
I don't seem to be able to replicate this.

Here's two test cases, one editing an existing record, one with a new form ...

New:

http://screencast.com/t/urarU49r

Edit:

http://screencast.com/t/VRoVgDnNM

If I'm misunderstanding, give me the exact steps I need to take to duplicate the problem you are seeing.

Also, what other elements do you have on your page, and are you seeing any JS errors during any of this, on original page load, or when submitting, or when the failed validation page reloads?

-- hugh
 
The problem is with additions to the picklist. If there is an addition and validation fails, the addition value is still in the hidden addition element, not in the To or From fields of the picklist. You can see it in firebug. So when the form is saved the addition is also saved to the element even when the user doesn't perform the addition again.

I have php validation logic that tests the value of the addition and will fail the validation under certain circumstances. The picklist reverts back to its correct condition before any changes but the addition is left over in the hidden element.

I probably didn't explain that very clearly the first time.
 
Also, to answer your other questions, the picklist is the only element on the form and I am seeing no JS errors reported by Firebug.
 
Oh, crap, well I don't even have to look at the code to tell you that's going to be a sod.

I'll give it a quick go though, as I recall having a similar issue with the dropdown element, so if I can cop the code from that, we'll be oK.

-- hugh
 
OK, this is indeed a pig. The code is sufficiently different to the dropdown stuff, that I can't just copy it. It'll be about an hour's work to implement and test the various combinations (save additions, label only, label and value).

-- hugh
 
Yeah, that's going to be non-trivial. You jinxed yourself when you said "I imagine this is relatively straightforward to correct". Whenever anyone says they think something should be easy / simple / straightforward, that's pretty much like casting a spell which ensures it'll be a nightmare. This issue isn't quite a nightmare, but definitely not a trivial fix, and I don't have time to work on it in Community right now.

I'll try and make some time, but I'm hurting on getting bills paid this month (the 35% drop in Euro to USD exchange rate in the last few months is killing me!), and have to take care of some bizniss first.

-- hugh
 
I hear you. I have the same problem with the drop in exchange on the US to Canadian Dollar but not nearly as dramatic as your situation.

I have an idea I might be able to solve the problem in a php form submission plugin. Will work on that today.
 
I was indeed able to get around the problem in a php form plugin. Testing the element form values against what is in the additions and what is in the fabrik element I am able to determine if any addition was leftover from the validation failure. I am then able to push the correct data back to the form for further processing.

Until such time as Hugh gets a chance to fix the underlying problem this will get me through. Should anyone else run into the problem feel free to post here and I will provide more details and assistance if I can.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top