Validation still check on readonly element

black.be3

Member
Hi,
I have dropdown element that have validation notempty, it only editable for special.
This is what happen:
1. I logged as administrator fill out my form including dd element that have validation. I can save the record.
2. I logged as registered, edit the record and fill/change element value that are editable for registered. In this situation, the dd element is readonly. When i try to save the record i got 2 warning
first : Some parts of your form have not been correctly filled in
second :JUser: :_load: Unable to load user with id: 1
When this error occur, elements on my form contain no value, why... :confused:

is it normal that validation still check even if the element readonly? once i was experiencing on f2, that even when element is unpublish, the validation still running

on error, why my elements contain no value?






I dont know
 
What are the option values on your dropdown element?

AFAIK, in f3, we don't allow you to save a dropdown with an empty option value. So I'm not sure why you would have a 'notempty' validation on a dropdown, if you can't have a dropdown value which is "empty". This isn't really relevant, I'm just curious as to whether we allowed you to set a dropdown option value as empty.

Anyway ... I'm testing a tweak to our shouldValidate() method which would skip validation if the user doesn't have Edit access on the element. I'll commit it to github some time today.

-- hugh
 
After some more testing, I think I've fixed the underlying issue, which is that 'read only' data wasn't being correctly appended to the form.

What should have been happening is that read only element data gets appended to the form as hidden form inputs, with the data encrypted. On submission, we then take that encrypted data, un-encrypt it, and stuff it back in to the main form data structure. So it's then available to things like validation rules.

Long story short, the read only element data wasn't being correctly included in our hidden, encrypted form fields. So when your validation ran, the read only element had no data in it, and hence failed the validation.

So my original fix described in my previous post (not validating an element if it's read only) was not the right fix. We should still validate it (I can think of several cases where one would definitely want read-only data to be validated). And now, with the right fix in place, we can.

I'm testing the new change, and don't want to commit it till I've run it for a day or so. Please bump this thread in 24 hours, and I'll commit the fix for you.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top