Index: themes/modern-store/inc/js/form_manager.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- themes/modern-store/inc/js/form_manager.js (revision 15775) +++ themes/modern-store/inc/js/form_manager.js (revision ) @@ -180,12 +180,8 @@ } FormManager.getURL = function ($prefix, $template, $event, $params) { - var $url = this.form_param($prefix, 'url'); + var $url = this.getUrlMask($prefix); - if (!$url) { - $url = this.url; - } - if ($template === undefined) { $template = this.form_param($prefix, 'template'); } @@ -205,6 +201,23 @@ return $url; } +FormManager.getUrlMask = function ($prefix) { + // 1. look in form config + var $url = this.form_param($prefix, 'url'); + + if ( !$url ) { + // 2. look at 'action' attribute of a form + $url = this.getForm($prefix).attr('action'); + } + + if ( !$url ) { + // 3. use global fallback url + $url = this.url; + } + + return $url; +}; + FormManager.processResponse = function ($prefix, $data, $add_params) { // enable form back // alert('enabling for for [' + $prefix + '] in processResponse'); @@ -378,8 +391,8 @@ } FormManager.validateField = function ($prefix, $field, $input) { - var $me = this; - var form = document.getElementById( this.form_param($prefix, 'form_id') ); + var $me = this, + form = this.getForm($prefix); var $request = $.post( this.getURL($prefix, undefined, 'OnValidateField') + '&field=' + encodeURIComponent($field) + '&' + $input.name + '=' + encodeURIComponent($input.value), @@ -501,8 +514,7 @@ } } - var form = document.getElementById( this.form_param($prefix, 'form_id')), - $form_fields = $(form).serialize(); + var $form_fields = this.getForm($prefix).serialize(); // restore original values into input fields for (var $i = 0; $i < $fields.length; $i++) { @@ -515,6 +527,12 @@ return $form_fields; } + +FormManager.getForm = function ($prefix) { + var $form_id = this.form_param($prefix, 'form_id'); + + return $('#' + jq($form_id)); +}; FormManager.enableForm = function ($prefix, $enabled) { if ($enabled === undefined) { \ No newline at end of file Index: themes/advanced/platform/inc/form_manager.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- themes/advanced/platform/inc/form_manager.js (revision 15775) +++ themes/advanced/platform/inc/form_manager.js (revision ) @@ -151,12 +151,8 @@ } FormManager.getURL = function ($prefix, $template, $event, $params) { - var $url = this.form_param($prefix, 'url'); + var $url = this.getUrlMask($prefix); - if (!$url) { - $url = this.url; - } - if ($template === undefined) { $template = this.form_param($prefix, 'template'); } @@ -176,6 +172,23 @@ return $url; } +FormManager.getUrlMask = function ($prefix) { + // 1. look in form config + var $url = this.form_param($prefix, 'url'); + + if ( !$url ) { + // 2. look at 'action' attribute of a form + $url = this.getForm($prefix).attr('action'); + } + + if ( !$url ) { + // 3. use global fallback url + $url = this.url; + } + + return $url; +}; + FormManager.processResponse = function ($prefix, $data, $add_params) { // enable form back // alert('enabling for for [' + $prefix + '] in processResponse'); @@ -472,8 +485,7 @@ } } - var form = document.getElementById( this.form_param($prefix, 'form_id')), - $form_fields = $(form).serialize(); + var $form_fields = this.getForm($prefix).serialize(); // restore original values into input fields for (var $i = 0; $i < $fields.length; $i++) { @@ -486,6 +498,12 @@ return $form_fields; } + +FormManager.getForm = function ($prefix) { + var $form_id = this.form_param($prefix, 'form_id'); + + return $('#' + jq($form_id)); +}; FormManager.enableForm = function ($prefix, $enabled) { if ($enabled === undefined) {