use jquery validation

This commit is contained in:
Uwe Steinmann 2021-05-28 14:18:26 +02:00
parent 07919b0810
commit d325340e0b

View File

@ -33,7 +33,23 @@ class SeedDMS_View_WorkflowMgr extends SeedDMS_Theme_Style {
function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8');
parent::jsTranslations(array('js_form_error', 'js_form_errors'));
?>
function runValidation() {
$("#form1").validate({
rules: {
name: {
required: true
},
initstate: {
required: true
},
},
messages: {
name: "<?php printMLText("js_no_name");?>",
}
});
}
function checkForm(num)
{
@ -154,8 +170,7 @@ $(document).ready(function() {
}
}
?>
<?php $this->contentContainerStart(); ?>
<form class="form-horizontal" action="../op/op.WorkflowMgr.php" method="post" enctype="multipart/form-data">
<form class="form-horizontal" action="../op/op.WorkflowMgr.php" method="post" enctype="multipart/form-data" id="form1" name="form1">
<?php
if($workflow) {
echo createHiddenFieldWithKey('editworkflow');
@ -169,6 +184,7 @@ $(document).ready(function() {
<input type="hidden" name="action" value="addworkflow">
<?php
}
$this->contentContainerStart();
$this->formField(
getMLText("workflow_name"),
array(
@ -191,10 +207,10 @@ $(document).ready(function() {
'options'=>$options
)
);
$this->contentContainerEnd();
$this->formSubmit('<i class="fa fa-save"></i> '.getMLText("save"));
?>
</form>
<?php $this->contentContainerEnd(); ?>
<?php
if($workflow) {
$actions = $dms->getAllWorkflowActions();
@ -250,7 +266,7 @@ $(document).ready(function() {
}
echo "</tbody></table>";
?>
<form class="form-inline" action="../op/op.AddTransitionToWorkflow.php" method="post">
<form class="form-inline" action="../op/op.AddTransitionToWorkflow.php" method="post" id="form2" name="form2">
<?php
echo "<table class=\"table table-condensed\"><thead></thead><tbody>";
echo "<tr>";
@ -294,7 +310,7 @@ $(document).ready(function() {
?>
<?php echo createHiddenFieldWithKey('addtransitiontoworkflow'); ?>
<input type="hidden" name="workflow" value="<?php print $workflow->getID();?>">
<input type="submit" class="btn" value="<?php printMLText("add");?>">
<input type="submit" class="btn btn-primary" value="<?php printMLText("add");?>">
<?php
echo "</td>";
echo "</tr>\n";
@ -319,6 +335,9 @@ $(document).ready(function() {
$workflows = $this->params['allworkflows'];
$workflowstates = $this->params['allworkflowstates'];
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
$this->htmlStartPage(getMLText("admin_tools"));
$this->globalNavigation();
$this->contentStart();
@ -352,7 +371,7 @@ $(document).ready(function() {
$this->columnEnd();
$this->columnStart(7);
?>
<div class="ajax" data-view="WorkflowMgr" data-action="form" <?php echo ($selworkflow ? "data-query=\"workflowid=".$selworkflow->getID()."\"" : "") ?>></div>
<div class="ajax" data-view="WorkflowMgr" data-action="form" data-afterload="()=>{runValidation();}" <?php echo ($selworkflow ? "data-query=\"workflowid=".$selworkflow->getID()."\"" : "") ?>></div>
<?php
$this->columnEnd();
$this->rowEnd();