Skip to content

Commit

Permalink
dispatch submit event from div.ui.form to native form
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed May 21, 2023
1 parent ff7f4be commit e303679
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +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()->form('submit');
$this->on('submit', new JsExpression('if (event.target === this) { []; }', [$jsSubmit]));
$jsFormElementSubmit = $this->js(false, null, $this->formElement)->form('submit');
$this->on('submit', new JsExpression('if (event.target === this) { []; }', [$jsFormElementSubmit]));

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

0 comments on commit e303679

Please sign in to comment.