processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

Profields Repeater Matrix does not save values if form submitted with Enter key (missing type='button')

Open hiboudev opened this issue 1 year ago • 1 comments

Quite a strange issue, tested on Firefox and Chrome.

If I press enter after editing the field inside matrix repeater, form is submitted but the new value is not saved. It's saved only if I click save button. The field inside is an Integer, I tested with a Text, same issue. So if I add multiple new items and press Enter, new items are lost.

I'm using link buttons, but switching to default mode has this issue too.

  • ProcessWire version: 3.0.228, Matrix v11

EDIT : It's not only if I press Enter in Matrix, it's in any field in the page. But if I remove Matrix from this template there's not more issue, so it probably comes from a JS code inside this module.

EDIT 2 : I tried to investigate, it solves the issue if I delete hidden span element of class InputfieldRepeaterMatrixAddSelectWrap, or just delete the uk-button inside ("Select type to add…").

EDIT 3 (and last one) : How to fix

In InputfieldRepeaterMatrix.module, line 825, add this attribute to button: type='button' $button = "<button type='button' class='uk-button uk-button-text'>$addLabel</button>";

I know this type='button' is necessary if a button in a form should not submit it, but I'm a bit surprised of what kind of issue it produced here. But the most surprising... is that nobody has reported it before.

hiboudev avatar Nov 22 '23 02:11 hiboudev

Can confirm this bug. I found the culprit to be at line 825 in InputfieldRepeaterMatrix.module, v011. See this post on the PW Forum for all I tried before adding this fix: https://processwire.com/talk/topic/29377-page-edits-do-not-get-saved-when-a-matrix-field-is-present/

eelke avatar Dec 21 '23 07:12 eelke