Skip to content

Commit

Permalink
Revert "on enter submit handler is then not needed/loops"
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed May 21, 2023
1 parent d12be36 commit 3f8b9bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,14 @@ protected function initLayout(): void
->addMoreInfo('layout', $this->layout);
}

// allow to submit by pressing an enter key when child control is focused
$jsSubmit = $this->js(false, null, $this->formElement)->form('submit');
$this->on('submit', new JsExpression('if (event.target === this) { []; }', [$jsSubmit]));

// Add save button in layout
if ($this->buttonSave) {
$this->buttonSave = $this->layout->addButton($this->buttonSave);
$this->buttonSave->setAttr('tabindex', 0);
$jsSubmit = $this->js(false, null, $this->formElement)->form('submit');
$this->buttonSave->on('click', $jsSubmit);
$this->buttonSave->on('keypress', new JsExpression('if (event.keyCode === 13) { []; }', [$jsSubmit]));
}
Expand Down

0 comments on commit 3f8b9bb

Please sign in to comment.