Hi I have a modal contact form on my site that is available on each page of my site. When I render the contact controller on each page I was trying to use this
{% render controller('CorporateSiteBundle:Forms:contactUs', { 'contactOpen': contactOpen is defined, route: app.request.requestUri}) %}
Then on my controller page from all my contact form I wanted to grab that 'route' value that I was sending over. This is what I used:
$request->query->get('route');
But the form just seems to fail when it submits. Can anyone help with where I'm going wrong? Thanks
you should try with
$request->get('contactOpen');
Related
I am a total beginner in Symfony. I would like to implement a master detail view in Symfony. So I have a table with user entries shown in a twig template. If a user clicks one of the rows, in the lower part of the page the users details should be shown. How is this best done with Symfony?
Should I use a fragment with hidden content if the parameter from controller for details is empty?
e.g. {% if .... }
Should I use javascript to call the controller action?
Thank you.
I have a very short question regarding Silverstripe. I have not found a solution anyway on the internet or here. I currently have a form on SS4 that when submit it will run an AJax request and render new content (page). The problem I have is that the content does not display and it seems to be related to the fact that the content that is rendered in is managed by a different Page controller. So it could not find the content when rendering through Ajax from another page. How would I resolve this without refreshing the page ?
Thanks in advance !
you would submit to the same page, which has a function to generate/return the new page. note that when submitting via ajax you need to include the FormAction button in the submitted fields.
I my application i have a listview representing News-items. On each row end i want to add a plus-sign button and by clicking it, a little inline form should pop up in a bubble (via bootstrap dropdown). To render this form, my actually approach is to render this via the render(controller(...)) mechanism in the field template.
{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}
{% block field %}
{{ render(controller(...)) }}
{% endblock %}
The render controller call renders a form according to the official symfony documentation ...
The rendered form sends it data back to the commentAction in the same controller.
In theory it works fine, but practical its slow as hell. My site runs in timeout after 60 seconds just because in the listview are default 64 items shown and each item calls this render controller function ...
Is there a clean way to render a little extra form not by invoking a expensive render controller call?
I think it could work with manipulating the listAction method in the controller (injecting here the extra form?) ... but this does not seem a clean solution.
Any ideas?
Thanks
Edit:
Ok, i think i found out, where the bottleneck is ... the example above was simplified. In reality i load a collection into the form for every row ... in the form you can choose, which author created the news. There are at least 500 Authors in that list ... so displaying these authors for a single new, everything is fine. But rendering the choose options 64 times is too much. Is there a way to make this faster? Some caching mechanism?
I think in this case, instead of rendering all forms at once, just load the form via AJAX once user click on the button. Another solution could be to replace collection for some autocomplete somyou dont need to render all data at once.
I am using the FOSUserBundle in my Symfony application,
I have the login and register forms in a separate template. I want both in one template to display them next to each other.
plz help me save my day !!
1 You need to have a first controller with a loginAction that renders a login.html.twig template. Let's assume this controller is AcmeUserBundle:Security:login.
2 You need to have a second controller with a registerAction that renders a register.html.twig template. Let's assume this controller is AcmeUserBundle:Registration:register
3 Create a third controller, for example welcomeAction that renders a welcome.html.twig template, and embed the controllers above on the same page.
{# AcmeUserBundle:Welcome:welcome.html.twig #}
{{ render(controller('AcmeUserBundle:Security:login'})) }}
{{ render(controller('AcmeUserBundle:Registration:register'})) }}
See here for more informations on how to embed controllers.
I have created a plugin, its adds an admin menu page for the menu. The page contains a form.
What I want to know is what is the suggested convention/method of handling form submissions.
Should I load the page and in that check for the $_POST ?
Should I load a separate form page ?
Thanks.
DETAILS:
The thought behind is:
I would want to load a new page and have my submit code it in, but would want to follow convention and the login/rules of capabilities.
(moved into wordpress.stackexchange.com)
You can use a form page into your plugin and when you load the page you check the $_POST like this
//At the page load
if( isset( $_POST["MyForm"]))
{
action();
}
//The Form
<form name="MyForm" method="POST" action="">
</form>
To load the new page if you have submit you have 2 solutions, in the "action()" you generate another page via PHP or you redirect to the other page you want but you have to register it to Wordpress unless you'll have an access denied.
Personnaly i suggest to generate your page into your plugin.