Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

JSON javascript code in Aform.php what does it do?

 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 11-19-2017, 02:29 AM
 
madhatter717 madhatter717 is offline
 

Member
  
Join Date: Oct 2016
Posts: 24
 

Default JSON javascript code in Aform.php what does it do?

I found the following code in XLite\class\view\form\Aform.php:

/**
* javascript: this value will be returned on form submit
* NOTE - this function designed for AJAX easy switch on/off
*
* @return string
*/
protected function getOnSubmitResult()
{
return 'true';
}

/**
* javascript: default action performed on form submit
*
* @return string
*/
protected function getJSOnSubmitCode()
{
return 'return ' . $this->getOnSubmitResult() . ';';
}

What I cant seem to find is the function getJSOnSubmitCode, I would like to know what this code does and where I can find it.
Obviously it relates to the xcart forms and it does something once you submit a form. I am about to create a custom form module for our site, but before I do I would like to know what this code does and where I can find it, so I can determine if I should leave it in my custom form module.

Thanks in advance
__________________
x-cart business 5.2.14
Reply With Quote
  #2  
Old 11-26-2017, 09:44 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: JSON javascript code in Aform.php what does it do?

Here is where the code goes into: skins/admin/modules/XC/CanadaPost/form/start.twig:
Code:
<form action="{{ this.getFormAction() }}" method="{{ this.getParam('formMethod') }}" accept-charset="utf-8" onsubmit="javascript: {{ this.getJSOnSubmitCode() }}" {% if this.getParam('className') %} class="{{ this.getClassName() }}"{% endif %} {% if this.isMultipart() %} enctype="multipart/form-data"{% endif %} {% if this.getParam('attributeTarget') %} target="{{ this.getParam('attributeTarget') }}"{% endif %}> <fieldset> {% for paramName, paramValue in this.getFormParams() %} <input type="hidden" name="{{ paramName }}" value="{{ paramValue }}" /> {% endfor %} </fieldset>

And here: skins/customer/form/start_order_search.twig:
Code:
<form action="{{ this.getFormAction() }}" method="{{ this.getParam('formMethod') }}" accept-charset="utf-8" onsubmit="javascript: {{ this.getJSOnSubmitCode() }}" class="search-orders" style="display: none;"> <div class="form-params" style="display: none;"> {% for paramName, paramValue in this.getFormParams() %} <input type="hidden" name="{{ paramName }}" value="{{ paramValue }}" /> {% endfor %} </div>

There are no other templates that use the method directly, but, as far as I see, the "onsubmit" attribute is added to other forms in a similar way automatically.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions

Last edited by qualiteam : 11-26-2017 at 09:48 PM.
Reply With Quote
  #3  
Old 11-27-2017, 08:29 AM
 
madhatter717 madhatter717 is offline
 

Member
  
Join Date: Oct 2016
Posts: 24
 

Default Re: JSON javascript code in Aform.php what does it do?

Thanks so much guys,
__________________
x-cart business 5.2.14
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:45 PM.

   

 
X-Cart forums © 2001-2020