Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: conflict issue with Forms add-on from DevDemon

Status Resolved
Add-on / Version Publisher 2.7.3
Severity
EE Version 3.5.15

pixiwooh

Mar 02, 2018

Hi again,
So, here is the complete issue:

I have Publisher installed with “Add URL prefix” set to YES. I have Forms from DevDemon installed. I have a form (just in French for now) that is the core of the website.
When I try to submit the form, it leads to nowhere (404). When I switch off Publisher to see if the issue is because of a conflict between Forms and Publisher, the forms works properly (it goes to validation process). Just by deleting the language prefix in the URL it also works. That is why I thought the issue is in the URL rewritting maybe?

I tried to add data-publisher-ignored=“yes” parameter to the form tag but it didn’t solve the issue.

I made a bare template as you asked me to do.

Detailed steps to reproduce the issue:
1. Switch on Publisher
2. Go to the form page (with the language prefixed URL then)
3.Click on submit button
4. See that it leads to nowhere.

Thank you in advance.

PS : because it is in dev, you have to be logged in to see the website.

#1

BoldMinded (Brian)

Have you tried version 2.7.6 yet?

#2

pixi

Just tried : the issue persists.

#3

BoldMinded (Brian)

The form does not have an action. Try giving it a url to submit to, even if its the current url.

<form id="new_submission" class=" plainte_standard_fr" method="post" action="" enctype="multipart/form-data">
#4

pixi

Unfortunatelly Forms addon doesn’t give the power to change the action’s parameter value.

#5

BoldMinded (Brian)

I’m about 99.9% sure the issue is with your configuration of the form, or something else on your site (something server side, htaccess, or whatever) b/c I was able to create a basic form with 1 field using all the default settings and it submits fine in the default and non-default language of my demo site which is using a language prefix in the url. Screencast of it working: https://d.pr/i/etelHM

#6

BoldMinded (Brian)

Also, both of these modules have been around since EE2, and I rarely hear of conflicts between the two. Many people use them in combination, which is why I’m lead to believe its a configuration issue on your side. Try setting up a new EE 2 site with nothing but Publisher and Forms installed, and use the default settings of both but just create a 2nd language and enable url translation prefixes, then make a simple form and see if it submits as it does in my screencast.

#7

pixi

Just did what you asked me to do (a fresh empty EE3 install with nothing but Publisher and Forms installed etc…) and got the same issue.

In fact, if I fill in all the requested inputs (as you did in your demo) it send the form properly. But the issue is when all the requested inputs are not properly filled.

I tested a little more further and saw that if I remove the language prefix into the URL mannually to kinda refresh the page but without the language prefix there is no problem, it leads to the form validdation process.

#8

pixi

Comment has been marked private.

#9

BoldMinded (Brian)

What is that error page? How did you define it to be displayed? Is it EE’s 404 page in the global Templates setting or something else?

#10

pixi

absolutely

#11

BoldMinded (Brian)

I’m not sure “absolutely” answered my questions 😊

#12

pixi

sorry : Is it EE’s 404 page in the global Templates setting 😊

#13

BoldMinded (Brian)

Check the http headers on the 404 page for “X-Publisher-Redirect”

#14

pixi

Comment has been marked private.

#15

BoldMinded (Brian)

Right click and Inspect the page and find your Network tab. I’m using Firefox, but Chrome has a very similar layout. You want to be looking at the Response Headers.

https://www.dropbox.com/s/a7eclfdx5uaydg3/Screenshot 2018-03-08 12.08.52.png?dl=0

#16

pixi

thanks. It seems that I dont have X-Publisher-Redirect https://d.pr/fAKUkE

#17

BoldMinded (Brian)

I’ll take another look at this tonight. If I still can’t replicate it would you be able to package up that fresh install you made with all the files and an .sql data dump so I can set it up locally and debug it?

#18

pixi

Of course! Let me know.

#19

BoldMinded (Brian)

I’m using Structure and this is what I found locally. I don’t think it applies to you but I want to document this incase someone else encounters it.

The issue is Forms is using EE’s native action requests to handle the post, and in this case Publisher is never called before Forms attempts to handle the error. The call stack:

https://www.dropbox.com/s/7d7hpqdd5aqfsg6/Screenshot 2018-03-13 07.03.09.png?dl=0

If the site is using Structure, Forms does not have the correct entry_id b/c the uri_string still has a language code in it. I suggest that the $entry_id parameter in the error handler be passed in via the POST data, or somehow via ee()->TMPL->fetch_param(‘entry_id’) so you can define the entry_id of the page

https://www.dropbox.com/s/12l6o7elsqx76yy/Screenshot 2018-03-13 07.03.56.png?dl=0

#20

BoldMinded (Brian)

TLDR; This isn’t a Publisher issue and I can’t fix it :/

The same thing is still true for when Structure is not available. The FormSubmission->handle_errors() method calls EE’s template parser before Publisher has a chance to do anything, so EE is thinking that the first segment which is the language code is a template group name, but it isn’t, so it can’t find a template to parse, thus it throws a 404. Its this code at the end of handle_errors() that is the problem. I’m always skeptical of add-ons that try to handle form submissions like this (a couple Solspace’s modules do this sort of thing too) and not let EE naturally do its thing. Its basically cutting Publisher out of the equation and not giving it a chance to do what it (or any other add-on) needs to do. I have a feeling the Transcribe module would do the same thing if you were using its language prefixing feature too.

ee()->load->library('template', NULL, 'TMPL');
                //ee()->TMPL = new EE_Template();
                ee()->TMPL->run_template_engine($template_group, $template);
                ee()->output->_display();
                exit();
#21

BoldMinded (Brian)

Nevermind, I take all that back. Apologies. I was debugging incorrectly. The issue is that Publisher does not perform any URL modifications, e.g. handling the language prefixes, if its an ACTION request, which is how Forms is submitting. I’m not sure how to fix this at the moment, so I’ll have to do some exploring.

#22

BoldMinded (Brian)

Ok, lets try this. In the Service/Session.php file on line 272 you’ll see this:

if (REQ == 'PAGE' && !$this->url->isTriggerWord()) {
                $this->validateUrl();
            }

Change it to:

if (!$this->url->isTriggerWord()) {
                $this->validateUrl();
            }
#23

BoldMinded (Brian)

Yep, I think that is the fix that we need. I’ve tested it in two different environments and will be including it in the next Publisher release.

#24

pixi

You gave a real emotional thrill ride along your 4 responses! –> 😊 :/ :( :D

Changing theses lines let me go to validation process of the form! YEAAH, thank you!

But… sorry there is a but :/ . When on validatio process every single Publisher tag (phrases, variables, early parsed variables,…) isn’t parsed around the page : I have for example {phrase:menu_organisation_rubriquenom} in place of “Organisation”…

#25

BoldMinded (Brian)

Yes that was a bit of a roller coaster 😊

To fix that new issue in Session.php line 292 remove the conditional around these method calls

if (REQ == 'PAGE') {
            // Create {page_uri:XX} and {publisher:*} vars
            ee()->load->model('publisher_site_pages');
            ee()->publisher_site_pages->create_page_uri_vars();
            $this->frontend->setGlobalVars();
        }
#26

BoldMinded (Brian)

Or change it to this, which may work too…

if (REQ == 'PAGE' || (REQ == 'ACTION' && !empty($_POST))) {
            // Create {page_uri:XX} and {publisher:*} vars
            ee()->load->model('publisher_site_pages');
            ee()->publisher_site_pages->create_page_uri_vars();
            $this->frontend->setGlobalVars();
        }
#27

pixi

It works 😊 Thank you very much! Awesome support, as usual.

#28

pixi

I’m back.

I have now buit the form in the other language and got the same issue for this form (not for the french one) : error 404…

Are you able to reproduce this on your install?

#29

BoldMinded (Brian)

It shouldn’t matter what the language is. The changes I made are language agnostic and will not prevent Forms from doing what it needs to do. The issue at this point is probably something else with your environment.

#30

pixi

I tried to reproduce the issue on my blank fresh new install and get the error as soon as I put translations into the “Template Translations” section of Publisher. Before I did Template Translations the issue wasn’t.

#31

pixi

a little more: actually, as far as the template translation equal the name of the template group, there is no problem (that is why I get no issue when vieuwing the website in french, as the template translation in french is the same as the template group name). But when I switch to another language, I got the issue when trying to go to validation process of the form.

#32

BoldMinded (Brian)

The reason it doesn’t work with template translations or routes is because the core_template_route hook is not fired when the form is submitted and when it tries to reload the page to show the error. Forms submits directly to an ?ACT url, which is fine, but it has code in it (mentioned above) that tries to determine if its a Page or Structure url, then goes on to call the run_template_engine method directly, which short cuts parts of EE out of its normal processes that determine how to render a page. I’m not a fan of how it is handling form submissions and returning error messages. It could easily cause conflicts with other add-ons since EE is not able to call the core_template_route hook (and potentially other hooks as well).

The Forms module should either post to the same url that the form is on, and then look at the POST array to determine what to do, or perform a redirect to the originating url after posting to the ?ACT url and display the error or success messages then. If it needs to perform a redirect and maintain the success or error messages it could save that data in a temporary flash variable.

I’m afraid there is nothing in Publisher I can change to make this work.

#33

BoldMinded (Brian)

Have you looked at the Forms documentation? It looks like there is a return parameter that you may be able to use to tell it where to go after posting. http://www.devdemon.com/documentation/tag/form/

#34

BoldMinded (Brian)

I may revert the change I made in the build I sent earlier because Publisher has been around for 5 years and I’ve never encountered a conflict like this with Forms before. I feel like that return parameter may be the key to this issue.

#35

pixi

Comment has been marked private.

#36

BoldMinded (Brian)

Who have you been talking too at DevDemon? I’ll reach out to them directly on this. I still feel like this is more of an issue on DevDemon’s side. Yes the issue is apparent when Publisher is installed, but its because publisher uses a hook that the forms module is bypassing. I’m not sure if working on this as a contract project will solve anything because I don’t feel like this is a Publisher bug, and I don’t want to add silly hacks to Publisher’s code or drastically change things just to make it work in this one use case. Like I said, I’ll reach out to DevDemon and see what they say.

Lastly, your English is fine 😊 If you didn’t say otherwise I would have assumed it was your first language.

#37

BoldMinded (Brian)

Does Forms support posting a form via ajax, then returning the error or success messages in the ajax response? If so you could save forms that way, then the page url never changes.

#38

pixi

Comment has been marked private.

#39

BoldMinded (Brian)

There are some references to handling Ajax form submissions in the Forms codebase, but I talked to Matt and it appears its not very well documented. Honestly I would suggest going that route, then you don’t have to worry about the URLs at all.

#40

BoldMinded (Brian)

I’m going to mark this ticket resolved b/c there isn’t anything I can do other than refactor a large portion of Publisher, which may not even fix the issue, and could very well break a lot of other things. I suggest looking into submitting the form via ajax and working with the folks over at DevDemon on how to do that.

#41

BoldMinded (Brian)

Just an FYI, there will be a change in the next version of Publisher, probably 2.7.10 where some of these changes may be reverted. It was causing problems with other add-ons. I’m still not a fan of how Forms feels like it needs to handle template rendering on its own. To me that isn’t very kosher b/c its disabling other add-ons from performing after a form is submitted and halts part of EE’s expected behavior. My recommendation is still to handle the form submissions entirely via ajax, and display the errors with JavaScript based on the ajax response.

Login to reply