How to response a view after receive a POST type in controller?

timothy259856

Active member
Hello!

I have a form contain a input with SubmitOnChange class, is there anyway to show a view like popup like the OverlayTrigger do? Thank you!

I do this in the controller

PHP:
public function actionQuickUpdate(){          
            $threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
            return $this->responseView('', 'my_template', array('thread_id' => $threadId));
        }
But alway receive this error!
Code:
Unspecified error
 
Last edited:
I don't quite understand what you're trying to accomplish. I see that you are trying to submit a form once a user changes a radio/checkbox input, and I assume that part is working. The "Unspecified Error" you are getting is probably coming from the alert that slides down from the top of the screen? The reason you are getting the unspecified error is because you haven't provided a response message. Are you trying to get an overlay to pop up after the form is submitted though?

If that is the case, we can probably figure out how to do it but it's going to require some additional work and most likely some custom javascript. Is there a reason you want an overlay to popup after the user has submitted the form?

I can certainly help you with this -- but I was just getting ready to head off to bed, so if you don't mind waiting, I can help you tomorrow. Maybe you can provide some more details for me while you wait?
 
The "Unspecified Error" you are getting is probably coming from the alert that slides down from the top of the screen?

Yes! :)

Are you trying to get an overlay to pop up after the form is submitted though?

Sure, yes! :)

If I use a <a> tag with OverLay class it's fine but don't get my purpose, what I mean is after user submit some data, I will catch that data and show a overlay popup.
 
Yes! :)



Sure, yes! :)

If I use a <a> tag with OverLay class it's fine but don't get my purpose, what I mean is after user submit some data, I will catch that data and show a overlay popup.
I just edited my post with a little bit of extra info and letting you know I won't be able to help you until tomorrow. I think I understand what you're going for, I can certainly help you to get trigger a popup after the form is submitted. I will post back here tomorrow -- if you can provide a specific example of what you want to happen in the meantime that would be helpful.
 
I just edited my post with a little bit of extra info and letting you know I won't be able to help you until tomorrow. I think I understand what you're going for, I can certainly help you to get trigger a popup after the form is submitted. I will post back here tomorrow -- if you can provide a specific example of what you want to happen in the meantime that would be helpful.

It's ok. Goodnight! I live in Japan so it's just 16:00 here :) See you tomorrow!

Is there a reason you want an overlay to popup after the user has submitted the form?

My idea is about the post reply function, it's a POST type, I want when user click submit button, I'll show a popup to require input captcha, then reroute the _input field to the right route to submit that post. Simple is that but still stuck at show popup until now. I just do small code about extend the controller to catch the post action and try to show the popup so the example code was nothing. Glad if you can help me. Thank you :)

P/S: Please ignore my bad English :(
 
Last edited:
It's ok. Goodnight! I live in Japan so it's just 16:00 here :) See you tomorrow!



My idea is about the post reply function, it's a POST type, I want when user click submit button, I'll show a popup to require input captcha, then reroute the _input field to the right route to submit that post. Simple is that but still stuck at show popup until now. I just do small code about extend the controller to catch the post action and try to show the popup so the example code was nothing. Glad if you can help me. Thank you :)

P/S: Please ignore my bad English :(
Are you comfortable with javascript? What you're trying to do is going to require quite a bit of javascript.

If you open up js/xenforo/full/xenforo.js and look for where XenForo.AutoValidator.prototype is defined (line 6971) you'll see it fires some events during the form submit process. If you're trying to hook into the reply feature, this is what you're going to want to use - as the reply forms get run through the AutoValidator. This is the line you're going to be interested in:

PHP:
/**
* Event listeners for this event can:
* e.preventSubmit = true; to prevent any submission
* e.preventDefault(); to disable ajax sending
*/
eDataSend = $.Event('AutoValidationBeforeSubmit')

This is the name of the event that gets fired before the form gets officially submitted.

For example, if I was going to tap into the quick reply form I would do something like this:

PHP:
$('#QuickReply').on('AutoValidationBeforeSubmit', function(event) {
    // this is where your javascript handling is going to go
    // this is where you will open your modal, most likely with a new form in it containing your captcha
    // your logic will go something like this:

    triggerOverlay(); // note this is not the function you will use, this part will be the hardest part

    if (validCaptcha) {
        // this is where we will re-submit the original data -- and allow it to go all the way through
    } else {
        // they entered an invalid captcha, we're going to prevent the form from submitting
        event.preventSubmit = true; // this will prevent the form from being submitted, nothing will happen
    }
});

Note that this is just a very rough sketch of what the logic will look like, this is by no means something you can just paste in and make work. What you are trying to do is not going to be overly simple by any means, so I can't write it all for you here without me writing the actual add-on for you.

What might be easier for you is to include the captcha ON the page with the form, instead of having a popup once they click the submit button. If you have the captcha on the form with the button, you can send their captcha value along with the post data -- validate the captcha in your PHP controller, and if it's valid then continue submitting the data, else if it's not valid you could send back an error saying it's not valid.

Does this at least point you in the right direction?
 
Are you comfortable with javascript? What you're trying to do is going to require quite a bit of javascript.

If you open up js/xenforo/full/xenforo.js and look for where XenForo.AutoValidator.prototype is defined (line 6971) you'll see it fires some events during the form submit process. If you're trying to hook into the reply feature, this is what you're going to want to use - as the reply forms get run through the AutoValidator. This is the line you're going to be interested in:

PHP:
/**
* Event listeners for this event can:
* e.preventSubmit = true; to prevent any submission
* e.preventDefault(); to disable ajax sending
*/
eDataSend = $.Event('AutoValidationBeforeSubmit')

This is the name of the event that gets fired before the form gets officially submitted.

For example, if I was going to tap into the quick reply form I would do something like this:

PHP:
$('#QuickReply').on('AutoValidationBeforeSubmit', function(event) {
    // this is where your javascript handling is going to go
    // this is where you will open your modal, most likely with a new form in it containing your captcha
    // your logic will go something like this:

    triggerOverlay(); // note this is not the function you will use, this part will be the hardest part

    if (validCaptcha) {
        // this is where we will re-submit the original data -- and allow it to go all the way through
    } else {
        // they entered an invalid captcha, we're going to prevent the form from submitting
        event.preventSubmit = true; // this will prevent the form from being submitted, nothing will happen
    }
});

Note that this is just a very rough sketch of what the logic will look like, this is by no means something you can just paste in and make work. What you are trying to do is not going to be overly simple by any means, so I can't write it all for you here without me writing the actual add-on for you.

What might be easier for you is to include the captcha ON the page with the form, instead of having a popup once they click the submit button. If you have the captcha on the form with the button, you can send their captcha value along with the post data -- validate the captcha in your PHP controller, and if it's valid then continue submitting the data, else if it's not valid you could send back an error saying it's not valid.

Does this at least point you in the right direction?

Wow! Many thanks for you! I'm not good about JavaScript even PHP (Just learn by myself) but with your explain, I understand all what you mean. Don't think about the Javascript before because I think that Xenforo has support that function but I still don't know :) I understand your mean and I'm sure that I can finish my purpose with your suggest.

What might be easier for you is to include the captcha ON the page with the form, instead of having a popup once they click the submit button. If you have the captcha on the form with the button, you can send their captcha value along with the post data -- validate the captcha in your PHP controller, and if it's valid then continue submitting the data, else if it's not valid you could send back an error saying it's not valid.
Yes! I was think to this after I have stuck with the show popup but still wanna to ask and hope someone can resolve that. And now I have two solutions for my purpose. Thanks for you very good support @Jeff Berry :)

Anyway, I'm just start develop addon for xenforo, learn by my self, so in the future, if I got problem, can I create thread and tag you in my post to help me?
 
Wow! Many thanks for you! I'm not good about JavaScript even PHP (Just learn by myself) but with your explain, I understand all what you mean. Don't think about the Javascript before because I think that Xenforo has support that function but I still don't know :) I understand your mean and I'm sure that I can finish my purpose with your suggest.


Yes! I was think to this after I have stuck with the show popup but still wanna to ask and hope someone can resolve that. And now I have two solutions for my purpose. Thanks for you very good support @Jeff Berry :)

Anyway, I'm just start develop addon for xenforo, learn by my self, so in the future, if I got problem, can I create thread and tag you in my post to help me?
The popup would be possible, and though XenForo has the popups built in, it doesn't necessarily have the ability to interrupt forms built in like you are looking for. I think it would be much easier for you to include the captcha on the page with the form, and just send that with the form itself instead of requiring the extra popup.

Yes, you are free to ask me any questions you like. I will try to help as much as I can. I don't wander these forums too often though, you can mainly find me over at my own site: www.xenreviews.com
 
The popup would be possible, and though XenForo has the popups built in, it doesn't necessarily have the ability to interrupt forms built in like you are looking for. I think it would be much easier for you to include the captcha on the page with the form, and just send that with the form itself instead of requiring the extra popup.

Yes, you are free to ask me any questions you like. I will try to help as much as I can. I don't wander these forums too often though, you can mainly find me over at my own site: www.xenreviews.com

Unfortunately, I cannot connect to your website, maybe my company has defend your server IP, hmmmm. Sadly!
 
Unfortunately, I cannot connect to your website, maybe my company has defend your server IP, hmmmm. Sadly!
Ahh :( I did have some issues a while ago where people were getting some false warnings saying my site was "malicious". I just installed an SSL certificate and some SiteLock software to hopefully resolve those issues. You may be able to access it now? If not hopefully within the next day or two at least.
 
Ahh :( I did have some issues a while ago where people were getting some false warnings saying my site was "malicious". I just installed an SSL certificate and some SiteLock software to hopefully resolve those issues. You may be able to access it now? If not hopefully within the next day or two at least.

Still not :(

Anyway, I'm going to public my first addon to this community. Glad to add you at my supporter :D
 
Ahh :( I did have some issues a while ago where people were getting some false warnings saying my site was "malicious". I just installed an SSL certificate and some SiteLock software to hopefully resolve those issues. You may be able to access it now? If not hopefully within the next day or two at least.

Sadly I still can't connect without disabling my firewall.
 
Sadly I still can't connect without disabling my firewall.
I sent out a few emails yesterday so I can hopefully get this issue cleared up once and for all. Unfortunately the last time I sent out these emails to the same people I never received a response. I've run malware scans from three different services and all of them come back clean. Not sure what the issue is.

You and I haven't had a chance to get acquainted yet, but by your signature I assume you own / are a part of pixelexit? If so, I may have some business to discuss with you. I was referred to you by some of my clients to get some custom work done for our project. If you're interested maybe we should move this conversation to PC?
 
Top Bottom