Data attributes on parent

Not sure if this is a v3 issue or even a Bricksforge issue, but when adding data attributes to a Select element in a Pro Form, it is rendered on the perent DIV (which I’m not sure is even valid inside a form) and not the Select element itself.

If this is a standard in BricksForge, it makes using Javascript difficult to target the correct element.

1 Like

Yes, unfortunately, all form elements get their attributes added to the wrapper div except the <option> and <optgroup> elements.

I had problems adding the step attribute to the number field before version 3.0. I was told I had to use JavaScript for that.

Also, you can probably adjust your JavaScript selector to target the child element you need. For example:

document.querySelector('[data-custom-id="my-select-field"] > select');

This is the way the Bricks API works for creating custom elements. All controls in “Styles” are automatically applied to the _root, which is the container. A change to completely dispense with a container for each element would be a major change that would affect the layout on many existing pages and quite a lot of work.

Are these only data attributes that represent a limitation? If so, I could create a new group for this in the “Content” area that specifically affects the inputs. What do you think?

Daniel, I suppose I’m struggling with being able to target an element directly rather than running up and down the DOM.

Ok, I can live with it, but I keep getting caught out

How are you dealing with ACF relationships? My approach is to provide a select list with a change listener that populates another select list with that selection, reset the original select element etc etc. Also then to have an evening listener on the second list in case the user needs to delete an entry.

I need not only the related records, but the specific order too (I’m matching people in an image to the people in a CPT) , so can’t see any other way to do it without emulating ACF’s own form control for dealing with relationships or to consider creating a custom form control

Your thoughts would be helpful.

Regards and thanks
Pete