codefog / contao-haste

Haste is a collection of tools and classes to ease working with Contao
http://codefog.pl/extension/haste.html
MIT License
43 stars 24 forks source link

[FORM] Removing inline event listeners #206

Closed doishub closed 1 year ago

doishub commented 1 year ago

I noticed that when I output a form via addFieldsFromDca in the frontend, I still get inline events for the backend delivered with it.

<select ... onchange="Backend.autoSubmit('tl_mytable')">

Is there already a way to remove attributes from the widget when the fields are built via the addFieldsFromDca?

qzminski commented 1 year ago

I think there is no automatic way to remove all backend listeners at once. However, we could maybe unset $arrData['eval']['submitOnChange'] before the form field is processed.

@Toflar @aschempp what do you think?

Toflar commented 1 year ago

Yeah, makes no sense in the FE. There are always going to be hacks like that as the DCA is just not meant to be used in the FE ;)

qzminski commented 1 year ago

But what would be the best way to strip this and others you think?

Toflar commented 1 year ago

Just remove submitOnChange, yes. It has no effect in the FE so remove it.

qzminski commented 1 year ago

@doishub can you try my fix 93dcdb9 ?

doishub commented 1 year ago

Works 👍 Thank you!

qzminski commented 1 year ago

Great! Please update to 5.1.2 stable.