forked from Wavyzz/dolibarr
Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into 21.0
This commit is contained in:
@@ -11379,7 +11379,7 @@ function printCommonFooter($zone = 'private')
|
||||
}
|
||||
|
||||
// Management of focus and mandatory for fields
|
||||
if ($action == 'create' || $action == 'edit' || (empty($action) && (preg_match('/new\.php/', $_SERVER["PHP_SELF"]))) || ((empty($action) || $action == 'addline') && (preg_match('/card\.php/', $_SERVER["PHP_SELF"])))) {
|
||||
if ($action == 'create' || $action == 'add' || $action == 'edit' || (empty($action) && (preg_match('/new\.php/', $_SERVER["PHP_SELF"]))) || ((empty($action) || $action == 'addline') && (preg_match('/card\.php/', $_SERVER["PHP_SELF"])))) {
|
||||
print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */'."\n";
|
||||
$relativepathstring = $_SERVER["PHP_SELF"];
|
||||
// Clean $relativepathstring
|
||||
@@ -11450,7 +11450,7 @@ function printCommonFooter($zone = 'private')
|
||||
// Solution 1: Add handler on submit to check if mandatory fields are empty
|
||||
print 'var form = $(\'#'.dol_escape_js($paramkey).'\').closest("form");'."\n";
|
||||
print "form.on('submit', function(event) {
|
||||
var submitter = event.originalEvent.submitter;
|
||||
var submitter = $(this).find(':submit:focus').get(0);
|
||||
if (submitter) {
|
||||
var buttonName = $(submitter).attr('name');
|
||||
if (buttonName == 'cancel') {
|
||||
@@ -11477,10 +11477,10 @@ function printCommonFooter($zone = 'private')
|
||||
if (tmpvalue === null || tmpvalue === undefined || tmpvalue === '' || tmpvalue === -1) {
|
||||
tmpvalueisempty = true;
|
||||
}
|
||||
if (tmpvalue === '0' && tmptypefield == 'select') {
|
||||
if (tmpvalue === '0' && (tmptypefield == 'select' || tmptypefield == 'input')) {
|
||||
tmpvalueisempty = true;
|
||||
}
|
||||
if (tmpvalueisempty) {
|
||||
if (tmpvalueisempty && (buttonName == 'save')) {
|
||||
console.log('field has type '+tmptypefield+' and is empty, we cancel the submit');
|
||||
event.preventDefault(); // Stop submission of form to allow custom code to decide.
|
||||
event.stopPropagation(); // Stop other handlers.
|
||||
|
||||
Reference in New Issue
Block a user