-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need to have unique id for fields in fieldsets #233
Comments
We also have this issue on production sites. |
As far as I know, there is no option to copy fieldsets in collective.easyform. If users manually try to reuse a name/id in 2 fieldsets, easyform prevents it due to a validation check. People could in theory bypass the validation by editing the xml directly, which leads to other validation issues on sent. |
@spereverde Could you expand a bit on what you mean by "honeypot solutions" ? |
@frapell sure.
In easyform there is a custom class field for this, in pfg I guess this honeypot field would be hidden with custom css or css inside a package somewhere, using the field's unique css id/class (= shortname of field). |
Maybe useful to note that we usually have this issue with old and new style fieldsets, and not with folders |
@spereverde Thanks! wasn't aware of such techniques :) |
I fear that this may break custom code, for example custom validators or scripts that expect to find "name" in the request, and now it should be "fieldset-name" or something. But I would only change these names/ids on the fly when it is really needed. So only change anything when there actually is a duplicate field name. |
For consistency, we might consider using validation as in easyform? |
Having 2 fields with the same
id
(i.e. when an existingfieldset
is copied) leads to unintended errors.Steps to reproduce:
FormFolder
FieldsetFolder
calledFolder 1
FormStringField
inside of it calledName
(It should default to255
forMax Length
, if not, make it so)FormFolder
go tofolder_contents
viewFolder 1
, clickcopy
and thenpaste
Folder 2
withfolder-2
as idAt this point, you should have a
/folder-1
and/folder-2
folders, and aname
field inside each of them.If you submit this form, you get
The reason for this, is because the form has 2 fields with the same
id
, and so when the form gets submitted, instead of having 2 separate values, they are merged and treated as a list with 2 values.Now, if you manually create the second folder, instead of copy & pasting, the field inside of it will be named
name-1
, which prevents this bug.A possible fix would be to add a subscriber so when pasting content, it will be traversed and all children would be renamed to avoid conflicts...
A better fix in my opinion would be to add a prefix to the field
id
andname
attributes qhen rendering the form, containing the fieldsets ids. So for instance in this case, the form would have 2 fields, one with anid
andname
offolder-1-name
and a second one withid
andname
offolder-2-name
The text was updated successfully, but these errors were encountered: