2
0
forked from Wavyzz/dolibarr

Add validate to module builder

This commit is contained in:
ATM john
2021-07-11 14:05:26 +02:00
parent a9a7315ce1
commit dc3f960ce8
3 changed files with 16 additions and 2 deletions

View File

@@ -176,6 +176,9 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
} }
$texttoinsert .= "),"; $texttoinsert .= "),";
} }
if ($val['validate']) {
$texttoinsert .= " 'validate'=>'".$val['validate']."',";
}
if ($val['comment']) { if ($val['comment']) {
$texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\""; $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
} }

View File

@@ -143,4 +143,5 @@ AsciiToHtmlConverter=Ascii to HTML converter
AsciiToPdfConverter=Ascii to PDF converter AsciiToPdfConverter=Ascii to PDF converter
TableNotEmptyDropCanceled=Table not empty. Drop has been canceled. TableNotEmptyDropCanceled=Table not empty. Drop has been canceled.
ModuleBuilderNotAllowed=The module builder is available but not allowed to your user. ModuleBuilderNotAllowed=The module builder is available but not allowed to your user.
ImportExportProfiles=Import and export profiles ImportExportProfiles=Import and export profiles
ValidateModBuilderDesc=Put 1 if this field need to be validated with $this->validateField() or 0 if validation required

View File

@@ -1303,7 +1303,8 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
'visible'=>GETPOST('propvisible', 'int'), 'enabled'=>GETPOST('propenabled', 'int'), 'visible'=>GETPOST('propvisible', 'int'), 'enabled'=>GETPOST('propenabled', 'int'),
'position'=>GETPOST('propposition', 'int'), 'notnull'=>GETPOST('propnotnull', 'int'), 'index'=>GETPOST('propindex', 'int'), 'searchall'=>GETPOST('propsearchall', 'int'), 'position'=>GETPOST('propposition', 'int'), 'notnull'=>GETPOST('propnotnull', 'int'), 'index'=>GETPOST('propindex', 'int'), 'searchall'=>GETPOST('propsearchall', 'int'),
'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha'), 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha'),
'css'=>GETPOST('propcss', 'aZ09'), 'cssview'=>GETPOST('propcssview', 'aZ09'), 'csslist'=>GETPOST('propcsslist', 'aZ09') 'css'=>GETPOST('propcss', 'aZ09'), 'cssview'=>GETPOST('propcssview', 'aZ09'), 'csslist'=>GETPOST('propcsslist', 'aZ09'),
'validate' => GETPOST('propvalidate', 'int')
); );
if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) {
@@ -2680,6 +2681,7 @@ if ($module == 'initmodule') {
print '<th>'.$langs->trans("KeyForTooltip").'</th>'; print '<th>'.$langs->trans("KeyForTooltip").'</th>';
print '<th class="center">'.$langs->trans("ShowOnCombobox").'</th>'; print '<th class="center">'.$langs->trans("ShowOnCombobox").'</th>';
//print '<th class="center">'.$langs->trans("Disabled").'</th>'; //print '<th class="center">'.$langs->trans("Disabled").'</th>';
print '<th>'.$form->textwithpicto($langs->trans("Validate"), $langs->trans("ValidateModBuilderDesc")).'</th>';
print '<th>'.$langs->trans("Comment").'</th>'; print '<th>'.$langs->trans("Comment").'</th>';
print '<th></th>'; print '<th></th>';
print '</tr>'; print '</tr>';
@@ -2712,6 +2714,7 @@ if ($module == 'initmodule') {
print '<td><input type="text" size="2" name="prophelp" value="'.dol_escape_htmltag(GETPOST('prophelp', 'alpha')).'"></td>'; print '<td><input type="text" size="2" name="prophelp" value="'.dol_escape_htmltag(GETPOST('prophelp', 'alpha')).'"></td>';
print '<td class="center"><input type="text" class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag(GETPOST('propshowoncombobox', 'alpha')).'"></td>'; print '<td class="center"><input type="text" class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag(GETPOST('propshowoncombobox', 'alpha')).'"></td>';
//print '<td class="center"><input type="text" size="2" name="propdisabled" value="'.dol_escape_htmltag(GETPOST('propdisabled', 'alpha')).'"></td>'; //print '<td class="center"><input type="text" size="2" name="propdisabled" value="'.dol_escape_htmltag(GETPOST('propdisabled', 'alpha')).'"></td>';
print '<td><input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag(GETPOST('propvalidate', 'alpha')).'"></td>';
print '<td><input class="text maxwidth100" name="propcomment" value="'.dol_escape_htmltag(GETPOST('propcomment', 'alpha')).'"></td>'; print '<td><input class="text maxwidth100" name="propcomment" value="'.dol_escape_htmltag(GETPOST('propcomment', 'alpha')).'"></td>';
print '<td class="center">'; print '<td class="center">';
print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">'; print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">';
@@ -2753,6 +2756,7 @@ if ($module == 'initmodule') {
$prophelp = $propval['help']; $prophelp = $propval['help'];
$propshowoncombobox = $propval['showoncombobox']; $propshowoncombobox = $propval['showoncombobox'];
//$propdisabled=$propval['disabled']; //$propdisabled=$propval['disabled'];
$propvalidate = $propval['validate'];
$propcomment = $propval['comment']; $propcomment = $propval['comment'];
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@@ -2823,6 +2827,9 @@ if ($module == 'initmodule') {
print '<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).'">'; print '<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).'">';
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print '<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).'">';
print '</td>';
print '<td>';
print '<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).'">'; print '<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).'">';
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
@@ -2888,6 +2895,9 @@ if ($module == 'initmodule') {
/*print '<td class="center">'; /*print '<td class="center">';
print $propdisabled?$propdisabled:''; print $propdisabled?$propdisabled:'';
print '</td>';*/ print '</td>';*/
print '<td class="center">';
print $propvalidate ? dol_escape_htmltag($propvalidate) : '';
print '</td>';
print '<td class="tdoverflowmax200">'; print '<td class="tdoverflowmax200">';
print '<span title="'.dol_escape_htmltag($propcomment).'">'; print '<span title="'.dol_escape_htmltag($propcomment).'">';
print dol_escape_htmltag($propcomment); print dol_escape_htmltag($propcomment);