templates - symfony - Call an action from view?


Question: 

I know it's not good to try to do this, but i would like to call an action in my view/template on symfony framework. Is it possible ? I don't find anything about this on the web.

Thanks you, and sorry for my bad english!!




1 Answer: 

As you know you should not call an action from the view layer. Actions are used to process form data and fetch page data, there should only be one action process per page imho. Perhaps a helper function or using a partial or component would be better for your needs.

Helper functions may be called at anytime and can most likely do what your second action needs to do. Short of forwarding or page routing, I believe a helper function can do anything an action function can. You need to use the Symfony getContext singleton for access to variables that are standardly loaded in an action.

Partials and components let you break up the view layer into separate chunks. Components actually get their own action code, but I wouldn't go crazy hitting the database or anything in a component, keep it simple. Partials pretty much let you call another template file from within a template.

Read more at http://www.symfony-project.org/gentle-introduction/1_4/en/07-Inside-the-View-Layer

 

More Articles


node.js - Get data having a maximum attribute from firebase in nodejs

So i am working with firebase in nodejs, there is a "number" attribute in each of my document of a specific table(name generated at runtime). I want to get the data having the attribute "number"'s maximum value.Here is my sample data:- -L1GIb7Vyn6Yhd5gghH0 correct: blah number: 9 questio

node.js - Hand Off Bot to Human using BotFramework (NodeJS)

I have crated a server application using botframework in NodeJS and configured for web chat channel in botframework.I want to validate the every reply that bot delivers to end user and those messages will be validated by human from an external web application.How can we trigger the bot from external

jquery - How do I access a child named with a random id in firebase?

I want to be able to automatically access every child named with random ID keys nested inside "posts", is there a way to get the children of every child inside them?I am completely new to firebase and managing database in general (started learning code 3 months ago), so I might have missed it in the


typescript - How to loop through child records in firebase?

I'm trying to figure out how to loop through sent_request child which is inside users table and get all user_keys. I tried many ways but it's not working.table structure: here is my code:getProfileData(emailID){ var ref = firebase.database().ref('users'); ref.orderByChild("email").equalTo(emai

actions on google - how can i get custom resolved values

the training phrases contain college subject domain/major like computer science engineering, mechanical engineering, information technology..... etc. i want the resolved values to beCS for computer scienceIT for information technologyMe for mechanical engineeringI am trying to figure this out for an

ruby - rails and balanced payments - Tokenize and add bank account

I'm using balanced payments with my rails 4 app and I need some help on how to tokenize and add a bank account. I'm not sure what I'm doing wrong. I read the docs and followed this gist . I'm getting a 200 ok status and I don't see any errors in the logs. However, when i check the response on my tes


Firefox extension to get google pagerank and alexa ranking

I am creating a Mozilla Firefox toolbar to show PageRank and Alexa ranking of current website. One way I came to know is to use XMLHttpRequest in my JavaScript file to get information from a PHP page hosted on my website's server. The PHP class has this function:function check($page) {// Open a soc

I came across the new Stack Overflow Bot by Microsoft on the Stack Overflow blog and decided to give it a try.After installing Node V8.1.4 for macOS, I installed the bot by running npm install in the StackBot directory. There weren't many issues, except for a warning returned.MacBook-Air:StackBot US

node.js - BotBuilder TypeError: builder.ConsoleConnector is not a constructor

I'm following the official quick start of Microsoft Bot Builder(SDK v3) for NodeJs: Create a bot with the Bot Builder SDK for Node.js 1- I made a new project with npm init2- then npm install --save botbuilder3- then I created a new file "app.js"var builder = require('botbuilder');var connector =

Logs showing WARNING when trying to credit bank accounts with Balanced Payments

Been seeing this in my logs today. ############################################################# # WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! # ############################################################# Using positional arguments is **DEPRECATED**. Please use the keyword optio