Rev 15337 | Rev 16841 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php$acl = $this->viewModel()->getRoot()->getVariable('acl');$currentUser = $this->currentUserHelper();$roleName = $currentUser->getUserTypeId();$routeSave = $this->url('settings/my-private-network/intro');$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));$this->inlineScript()->captureStart();echo <<<JSjQuery( document ).ready(function( $ ) {$.validator.setDefaults({debug: true,highlight: function(element) {$(element).addClass('is-invalid');},unhighlight: function(element) {$(element).removeClass('is-invalid');},errorElement: 'span',errorClass: 'error invalid-feedback',errorPlacement: function(error, element) {if(element.parent('.btn-file').length) {error.insertAfter(element.parent().parent());} else if(element.parent('.toggle').length) {error.insertAfter(element.parent().parent());} else {error.insertAfter(element.parent());}}});$.fn.handleDisable = function() {const disabledValue = $('button[type="submit"]').prop('disabled')$('button[type="submit"]').prop('disabled', !disabledValue);}$.fn.showFormErrorValidator = function(fieldname, errors) {var field = $(fieldname);if(field) {$(field).addClass('is-invalid');var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');if(element.parent('.btn-file').length) {error.insertAfter(element.parent().parent());} else if(element.parent('.toggle').length) {error.insertAfter(element.parent().parent());} else {error.insertAfter(element.parent());}}};var validator = $('#form').validate({debug: true,onclick: false,onkeyup: false,ignore: [],rules: {'intro': {updateCkeditor:function() {CKEDITOR.instances.intro.updateElement();},required: true},},submitHandler: function(form){var formdata = false;if (window.FormData){formdata = new FormData(form); //form[0]);}$.fn.handleDisable()$.ajax({'dataType' : 'json','accept' : 'application/json','method' : 'post','url' : $('#form').attr('action'),'data' : formdata,'processData': false,'contentType': false,}).done(function(response) {if(response['success']) {$.fn.showSuccess(response['data'], $.fn.handleDisable);} else {validator.resetForm();if(jQuery.type(response['data']) == 'string') {$.fn.showError(response['data']);} else {$.each(response['data'], function( fieldname, errors ) {$.fn.showFormErrorValidator('#form #' + fieldname, errors);});}}}).fail(function( jqXHR, textStatus, errorThrown) {$.fn.showError(textStatus);}).always(function() {NProgress.done();});return false;},invalidHandler: function(form, validator) {}});CKEDITOR.replace('intro');});JS;$this->inlineScript()->captureEnd();?><!-- Content Header (Page header) --><section class="content-header"><div class="container-fluid"><div class="row mb-2"><div class="col-sm-12"><h1>LABEL_MY_PRIVATE_NETWORK_INTRO</h1></div></div><div class="row mb-2"><div class="col-sm-12"><?php$form = $this->form;$form->setAttributes(['method' => 'post','action' => $routeSave,'name' => 'form','id' => 'form',]);$form->prepare();echo $this->form()->openTag($form);?><div class="form-group"><?php$element = $form->get('intro');$element->setAttributes(['id' => 'intro', 'class' => 'form-control', 'rows' => '2','class' => 'form-control']);// $element->setOptions(['label' => 'LABEL_INTRO']);// echo $this->formLabel($element);echo $this->formTextArea($element);?></div><div class="form-group"><button type="submit" class="btn btn-primary">LABEL_SAVE</button></div><?php echo $this->form()->closeTag($form); ?></div></div></div><!-- /.container-fluid --></section>