Autofill code from label when adding new extrafield

This commit is contained in:
Laurent Destailleur 2022-09-22 14:18:24 +02:00
parent 388dd6395b
commit 77c0e1f5d0

View File

@ -134,6 +134,12 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php<br>Contact:con
jQuery("#computed_value").keyup(function() {
init_typeoffields(jQuery('#type').val());
});
/* Autofill the code with label */
jQuery("#label").keyup(function() {
console.log("Update new field");
$("#attrname").val( $(this).val().replace(/[^a-zA-Z0-9_]/g, '').toLowerCase() );
});
});
</script>
@ -145,7 +151,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php<br>Contact:con
<table summary="listofattributes" class="border centpercent">
<!-- Label -->
<tr><td class="titlefieldcreate fieldrequired"><?php echo $langs->trans("LabelOrTranslationKey"); ?></td><td class="valeur"><input type="text" name="label" class="width200" value="<?php echo GETPOST('label', 'alpha'); ?>" autofocus></td></tr>
<tr><td class="titlefieldcreate fieldrequired"><?php echo $langs->trans("LabelOrTranslationKey"); ?></td><td class="valeur"><input type="text" name="label" id="label" class="width200" value="<?php echo GETPOST('label', 'alpha'); ?>" autofocus></td></tr>
<!-- Code -->
<tr><td class="fieldrequired"><?php echo $langs->trans("AttributeCode"); ?></td><td class="valeur"><input type="text" name="attrname" id="attrname" size="10" value="<?php echo GETPOST('attrname', 'alpha'); ?>" pattern="\w+"> <span class="opacitymedium">(<?php echo $langs->trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)</span></td></tr>
<!-- Type -->