When Store generates a form from a tag such as:

{exp:store:product entry_id="{entry_id}"}

This outputs the below:

<form method="post" id="" name="" class="store_product_form">
<div style="margin:0;padding:0;display:inline;">
<input type="hidden" name="return_url" value="products">
<input type="hidden" name="entry_id" value="45">
<input type="hidden" name="ACT" value="88">
<input type="hidden" name="RET" value="products">
<input type="hidden" name="site_id" value="1">
<input type="hidden" name="_params" value="Uy1bcQE4CWMFIFZ9AXhQDgsxU2cBLgAyBSYDZgA1UCcJfFUhUjYHOgVjDHZdeAF1UndXa105AlwLKAc2DHNVPFQ4U3FWdFI9D2cFLg==">
<input type="hidden" name="XID" value="6642e568194f9a1872e398f2739ce8aa591a6436">

Why is there no action="" set on this form? It appears to be using the ACT to submit to the index.php but if that isn't set in the config it falls over.

Is this an expression engine philosophy or just store?

I also wanted to know what the logic/thought behind this decision and if it's able to be modified?


It's a combination of Store's philosophy and ExpressionEngine's internals.

Leaving out the action attribute in a form tag is valid HTML5, and simply means "post to the current page". We've tested this back to IE6 and have found no compatibility issues.

Store used to use EE's native methods to get the current page URL, and use that when generating the form as the action attribute. However, these days lots of people are using plugins like Structure, and routing plugins like Freeway which modify the page URL, and trick EE into displaying a different page to the URL. In those cases, Store would submit the form to a different page than the current page, which would lead to unexpected behavior like displaying a totally different page if there were errors on the form. That is why it is preferrable to just tell the browser "post to the current page", and let the browser figure out the URL rather than trying to do anything complex in EE.

Now, the second part is how ExpressionEngine handles form submissions. If you POST to any url of an EE site, with an ACT parameter, EE treats this as an action request. It's exactly the same as requesting index.php?ACT=123 - the ACT parameter can be sent via POST or GET, it doesn't matter. In this case, the ACT parameter belongs to Store, which handles the form submission. Store processes the request, and if there were errors, it simply instructs EE to continue rendering the current page (which is why we post to the same URL, so we can display inline errors). If there were no errors, Store updates the cart, and redirects appropriately. This is exactly the same process Safecracker and many other add-ons use to render inline errors.

So, to answer your question - yes, it's expected behavior, and no, you can't change it (without hacking Store's files). I don't know what you mean by "if that isn't set in the config it falls over", but you shouldn't have to configure anything to make it work.

  • Thanks Adrian for the answer. As far as the last part of my question I'm using the Newism's config bootstrap: ee-garage.com/nsm-config-bootstrap and we had to specify this specific line on the staging site (gist.github.com/leevigraham/…). – James Nowland Jul 19 '13 at 2:03
  • Interesting. I don't see how that would affect form submissions, that should really just change whether or not you see index.php in the displayed URLs. – Adrian Macneil Jul 19 '13 at 11:33
  • Looks like a .htaccess issue if the servers default is index.html – James Nowland Jul 22 '13 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.