FAQ Database Discussion Community
symfony2,twig
I'm using a form on add and edit page in which there is a input file which is required for add record but it is not required on edit page. Is there a way to change attribute on different pages? $builder->add('title', 'text', array( 'required' => true, ))->add('description', 'textarea', array( 'required'...
symfony2,twig
I'm trying to override Resources/crud/actions/delete.php.twig from SensioGeneratorBundle. I created this file located at app/Resources/SensioGeneratorBundle/skeleton/crud/actions/delete.php.twig: {% extends "@SensioGenerator/Resources/crud/actions/delete.php.twig" %} {% block form %} /** * Creates a form to delete a {{ entity }} entity by id. * * @param mixed $id The entity id * * @return \Symfony\Component\Form\Form The form...
php,jquery,symfony2,twig
When I select a member from a Member list I need to get his default department from another select Department list on 'Add new member' form and, if necessary to change this member's department affiliation for a selected committee. I have two entities, Member and Dept. Dept is also a...
symfony2,twig
This question already has an answer here: Customize widget's ID attribute in Twig 3 answers So this is a pretty straightforward question but the solution seems not so straightforward to a twig beginner like myself. Basically, I want to apply some javascript to a set of forms, so I...
javascript,php,jquery,symfony2,twig
I've been searching for a while with no luck. I know my question looks mundane, and it has plenty (as in hundreds) of answers out in google and here, yet, still my problem seems far from solved. I have the following problem, I need to fill an input field, with...
symfony2,twig,silex
I'm trying to render a controller inside a twig template with this: {{ render(url('contact_form')) }} But I'm getting this error: An exception has been thrown during the rendering of a template ("Unable to add function "asset" as extensions have already been initialized.") I have a twig function called asset, like...
php,regex,symfony2,twig
I am currently working on symfony2 framework. I want the html data that twig file renders in one file. My code: $myfile = fopen("somefile.html", "w"); $data = $this->render("somefile.html.twig"); fwrite($myfile, $data); This works fine but in addition with html data I get the following line "HTTP/1.0 200 OK Cache-Control: no-cache Date: ...
php,email,symfony2,templates,twig
I've just pulled an all-nighter trying to get this to work, and I'm probably missing something foolish, but help me out. I have a symfony2 service which sends emails. I have injected the @templating service into my service's constructor like so: services.yml order_service: class: AppBundle\Services\OrderService arguments: [ "@doctrine.orm.entity_manager", "@mailer", "@templating"...
for-loop,twitter-bootstrap-3,twig
This question already has an answer here: How to handle twig view and bootstrap 3 rows/columns? 1 answer I loop through an array of tasks I want to show. Each element has bootstrap class col-md-3. The current behavior is to dump all them on one row. <div class="row"> {%...
angularjs,symfony2,twig
I'm using Symfony2 with Twig and AngularJS. I need to pass Twig variable to angular's function. Currently I tried doing that like this: ng-click="submitPost({{ channelName }})" but when I console.log to check that variable I see it as undefined. How do I pass Twig variables to angular functions?
javascript,symfony2,twig
I'm working on a Symfony2 project and I want to call a JavaScript function and pass an array of JSON objects (which I get from a controller) from a Twig. But a first, very simple test already failed, like: main.js: function helloWorld(name) { console.log("hello " + name); } linked to...
symfony2,twig
In my symfony2 action, i have: $twigCode = '<li>{{ data.value }}</li>'; //In database $datas = array(array( 'value' => 'line 1'), array( 'value' => 'line 2')); return $this->render( '...List.html.twig', array( 'twigCode' => $twigCode, 'datas' => $datas ) ); In my twig template, i want something like: <ul> {% for data in...
symfony2,twig
I am looking for best solution how to send value returned by one of entity function's in symfony2 to twig template. The problem is connecting with getting file url for file uploaded according to "How to Handle File Uploads with Doctrine" manual (http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html). I was following the last example ("Using...
php,forms,symfony2,twig
I'm trying to disable the frontend HTML5 validation for a filed in a form built in Symfony. In Twig, i use this code: {{ form_widget(form.email, {'attr': {'class': 'form-control input-lg','novalidate': 'novalidate}}) }} but the field is still considered as required. What am I doing wrong?...
arrays,forms,symfony2,twig
so I need to send array to other page. I was tried to make it by form: <form action="{{ path('_przepisy') }}" method="post"> <input type="hidden" name = "produkty" value = "{{ sniadanie }}"> <input type="submit" class="btn btn-success pull-right" value="Przepisy"/> </form> "sniadanie" is array, for example it works as: sniadanie[0]['ilosc'] On page...
php,security,symfony2,doctrine2,twig
I do in the application user registration, and I want to be notified by email when registering. I created for this services: app.mail_service: class: AppBundle\Mail\MailService arguments: ["@mailer", "@templating"] app.listener.user: class: AppBundle\EventListener\UserSubscriber arguments: ["@app.mail_service"] tags: - { name: doctrine.event_subscriber, connection: default } templating - TwigEngine MailService class: class MailService { private...
php,twig
This seems like a very basic question but I assure you I've run the gamut of solutions for this to work and I still haven't managed to find a solution. The problem is this: A twig value will be set with a value of 1, 0, or null by a...
symfony2,twig,html-sanitizing
I am investigating a possible XSS attack vector for my application. What I have: FormType with a single textarea field. Normally this field can contain html tags. Twig template that renders the data inserted. I use that form to insert the following content: <b>Some valid HTML text</b> <script type="text/javascript">alert("XSS")</script> Viewing...
javascript,symfony2,date,datetime,twig
I am working with Symfony, doctrine, twig and highchart.js. I need to create a chart with the js library and doctrine ORM data object. See my controller here: public function chartTestAction() { $em=$this->getDoctrine()->getManager(); $datasGraphique = $em->getRepository('mySpaceMyBundle:Graphique2')->findAll(); return $this->render('MySpaceMyBundle:myFolder:chartTest.html.twig', array('datasGraphique' => $datasGraphique) ); } So, my entity looks like this in...
php,mysql,arrays,multidimensional-array,twig
I'm trying to create multi level dropdown menu with mysql as store data, and i use twig as theme engine, i know there is ton of code outside but, all of them HTML as the output, since i use twig, so i need array as the output, and let twig...
php,symfony2,twig
In Twig partial rendered by separate controller, I want to check if current main route equals to compared route, so I can mark list item as active. How can I do that? Trying to get current route in BarController like: $route = $request->get('_route'); returns null. Uri is also not what...
symfony2,twig,rendering,choice
I have a problem which I cannot solve. How shall I approach the following: I have a choice field with 4 different entries, which I am rendering perfectly in a select form (twig). However, I would like to show the 4 entries as 4 separate buttons. How do I change...
php,symfony2,twig
I am implementing a simple custom login form. I am following two different example , the official one http://symfony.com/doc/current/cookbook/security/form_login_setup.html and this other one https://knpuniversity.com/screencast/symfony2-ep2/logout#play which is substantially the same but with some differences. Giving a look at the login.html.twig of the two examples, one of the differences is in the...
php,twig,block,slim
I would like to pass the id of a category into a parameter using urlFor(). {% for category in categories %} <br> <p><a href="{{urlFor('showTopic.post', {"cat_id": "{{category.id}}"})}}">{{category.category_title}}<a><br>{{category.category_description}}</p> <br> <br> {% endfor %} This currently does not work. It just passes in {{category.id}} instead of the actual id for the category. I...
php,symfony2,twig,swiftmailer
Hi I stumble upon this error everytime I want to run my Symfony application from console. Therefore I am unable to use this symphony app at all. Please help me with your knowledge. [Symfony\Component\Config\Exception\FileLoaderLoadException] Unable to parse at line 9 (near "mailer_transport="gmail"") in /opt/lampp/htdocs/symblog.dev/app/config/parameters.yml (which is being imported from "/opt/lampp/htdocs/symblog.dev/app/config/config.yml")....
html,symfony2,twig
I am using short conditional to discriminate the values displayed in a list of records. For example if I want the name of the customers who have a greater than 100 identifier are emphasized (<em> </em>) perform the following: {# Displays the identifier of the client #} {% set strClient...
symfony2,twig
How do you retrieve current hour for Symfony2?
php,twig
I'm using Twig as a standalone template engine for my site. I am using a simple router called Macaw that takes a "pretty URL" and tells Twig to render the appropriate page like so: Macaw::get('/(:any)', function($slug) { echo $GLOBALS['twig']->render('@pages/'.$slug.'.html'); }); It all works fine except if I try to load...
symfony2,twig
I'm using the {{ dump(foo) }} function in Twig to debug my templates. However, if the template is throwing errors after the dump() function, you will only see Symfony's debugging page informing you of the error. You can obviously comment out the offending lines of code in the Twig template,...
php,jquery,ajax,symfony2,twig
I have a problem when I want delete a register with Ajax and Symfony, in template Twig. <tbody> {% for entity in entities %} <tr> <td> <a class="delete btn btn-danger btn-xs glyphicon glyphicon-trash" data-playgroup-id="{{ entity.id }}" ></a> </td> </tr> {% endfor %} </tbody> Ajax: $(document).ready(function() { $(".delete").click(function(){ var pid =...
twig
In PHP I can designate which element / property to use simply by passing a variable with the name of it, such as: $array[$name] $object -> $name How to do this with Twig? For instance, with an array row read from MySQL database whose primary key field can be id,...
symfony2,twig,translation
I have this in my twig-template {{ returnDate|date("l, d.m.Y") }} The ouput is Friday, 08.05.2015. Its it possible to translate the dayname -> "l"? Something like this {{ returnDate|date("l, d.m.Y")|trans }}...
twig
Is there a way in twig to have a for every two loop? The best way I know to explain what I mean is to show you the result I'm looking for. <div class="row"></div> <div class="item"></div> <div class="item"></div> <div class="row"></div> <div class="item"></div> <div class="item"></div> <div class="row"></div> Is there some way...
laravel,twig
I'm trying to create a Laravel 5.1 package which uses Twigbridge instead of .php views. I can get normal .php views to display fine, but when I try to make use of .twig templates I'm only met with an error. Is it possible to use Twigbridge templates when creating views...
javascript,symfony2,twig
It's not about libraries, it's about custom scripts. I know two solutions: To write everything in one big file (many functions or custom library) To write pieces of scripts in twig templates Both solutions do not really like. In the first case, we must to copy assets after every update....
javascript,jquery,symfony2,twig
So I made a simple function with jQuery to check is it working and it isn't. I don't know why this happens since I did everything I found on other stack questions. It just does not do anything... Everything i have done by now: 1) I created the script and...
php,html,symfony2,templates,twig
I'm starting to optimize my website which is currently still with dev environment in Symfony2. I have one page which is quite wierd. The page load in ~1000ms and the twig template takes ~900ms based on Symfony profiler. I've looked at the twig template but it's quite big (lots of...
symfony2,twig
I have a dynamic form to create and i want to extend a widget in order to display it as <tr>. The fact is that each column of the table is a dynamic group containing some fields. All I want to do is iterate over groups in the myform_widget like...
symfony2,twig
I have a long Twig file like this: ... <th> {{('tree.overview.panel.column.name')|trans({},'jury')}} </th> <th> {{('tree.overview.panel.column.length')|trans({},'jury')}} </th> ... Using the trans_default_domain() I managed to shorten it to this: {% trans_default_domain "jury" %} ... <th> {{('tree.overview.panel.column.length')|trans }} </th> <th> {{('tree.overview.panel.column.phase')|trans }} </th> ... But I would like to create something even shorter and...
php,symfony2,routing,twig,url-routing
Let's say I have this code in a controller: <?php namespace Foo\BarBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration as Mvc; /** * @Mvc\Route("/foo/bar") */ class TestController extends Controller /** * @Mvc\Route("/test/{id}", requirements={"id" = "[0-9]{1,6}"}) * @Mvc\Template * * @return view */ public function testAction($id) { return array('test' => $id); } } How...
symfony2,twig
My layout.html.twig section contains all the bootstrap link .In my main twig file below i have used this following code. i am not able to load footer section. What am i doing wrong? {% extends 'HomeBundle:Main:layout.html.twig' %} {% block title %}English{% endblock %} {% block body %} <div id="sidebar"> {%...
css,google-chrome,twig,phpstorm,silex
I've run into a very frustrating bug. I can't reload changes in my css file. style.css seen in PhpStorm looks like: body { background-color: blue; } Yet seen in Chrome shows: body { background-color: green; } Here's the odd behaviour: If I change style.css to "foo bar testing" Chrome displays...
php,symfony2,templates,twig,fosuserbundle
I have a layout that looks like this: <html> <body> <!-- Omitted --> <div class="content"> {% block body %}{% endblock %} </div> <script src="js/vendor.js"></script> {% block javascripts %} <!-- I want to be able to inject inline scripts from sub-templates here --> {% endblock %} </body> </html> Then I have...
twig,slim
Hi I need interate twig to Slim application, I install twig with composer and im my script I have <?php use Slim\Slim; use Slim\Views\Twig; use Noodlehaus\Config; use Codecourse\User\User; session_cache_limiter(false); session_start(); ini_set('display_errors','On'); define('INC_ROOT', dirname(__DIR__)); require INC_ROOT.'/vendor/autoload.php'; $app = new Slim([ 'mode' => file_get_contents(INC_ROOT.'/mode.php'), 'view' => new Twig(), 'template.path' => INC_ROOT ....
symfony2,twig
Is it possible to use variable values for defining new twig globals in a configuartion-yml-file? The situation is, that we want to define the domain name at the one hand and at the other define often used paths (but using the already defined variable instead of writing the server name...
twig
Im having an issue with Twig where any timestamp I pass to the date filter I always get the current date, example: {{ 1433894400|date }} This should return the June, 10. But instead it returns the current date. I've tried passing a few different date formats but as expected it...
symfony2,twig
I am currently working on symfony2 framework. In one of my twig file FB.api( "/" + p_id + "/feed", "POST", { "message": "{{ des| replace({"\n":' ', "\r":' '}) }}", "description": "{{ des| replace({"\n":' ', "\r":' '}) }}", "access_token": p_accessToken }, function (response) { if (response && !response.error) { /* handle...
php,symfony2,twig
I've inherited a website that uses Symfony 2. The site was working fine until I ran composer to upgrade packages. It upgraded Symfony 2.6 to 2.7.1 and Twig 1.18 to 1.18.2. I now get the following error: Method "site" for object "Symfony\Bridge\Twig\AppVariable" does not exist in @Page/Page/homepage.html.twig at line 21...
symfony2,twig
I would like to find the file containing a block and the block to override to make a specific change. Is there a way to print this information out?...
php,symfony2,templates,twig
Let me describe a situation. You have a profile form and a form where users can upload personal profile related documents. Since the profile form is already very long the documents moved to a new form. Everything works great. Now we want to use the bootstrap tabs to do Profile...
php,symfony2,pdf-generation,twig,wkhtmltopdf
I need wkhtmltopdf on openSuSE. I have installed it via the repository. The version is 0.12.1. To render HTML with Symfony, I use the KnpSnappyBundle. By rendering a twig template, I got the following error message: The exit status code '1' says something went wrong: stderr: "wkhtmltopdf: cannot connect to...
symfony2,twig
I have the <title> tag defined as a block in my base twig file and I want to make sure all my views override this block. Is there a way to mark the block as required so I get an error if I forget?
symfony2,twig
I'm trying to create my first twig estension class UserExtension extends \Twig_Extension { public function getFunctions() { return array( new \Twig_SimpleFunction('userThumbImg', array($this, 'getUserThumbImg')), ); } public function getUserThumbImg() { $thumbImage = Repository::getInstance('users')->getUserImg(4, true); return $thumbImage['image']; } public function getName() { return 'user_extension'; } } The static repository class simply reads...
symfony2,twig,frontend,twig-extension
I'm trying to follow the atomic design pattern with twig. When rendering a simple atom, I need to do something like: {% include '@MyBundle/Resources/views/atoms/button/button.html.twig' with { href: '/section1', text: 'Example text' } only %} This approach starts getting messy when the atom or component has more variables, or the directory...
php,symfony2,twig
I'm playing around with a CMS idea for Symfony and I'm not sure if what I want to implement is possible. I'm looking for some guidance. I want to create a twig function that acts more like a block. I want to be able to write template like this: {%...
php,mysql,tinymce,twig,symfony-2.5
I am working on a project using symfony 2.5 It should be able to have a webpage that is editable text, bg color, bg image, and images etc. I use tinymce for inline editing. my question is how should I save these web pages to the database. I am going...
php,templates,session,twig
Let's say we have to manage user login and logout. We have an index.php file that by default shows the index.twig template (which contains a header to allow users login or signup. And we have another Twig template (welcome.twig) that's similar to index.twig template but, its header shows access to...
twig,where,bolt-cms
Bolt's docs say what you can use several ‘shortcuts’ for selecting records with dates in the past or future. And "Internally, Bolt uses the strtotime() funtion for this, so we refer to its manual page for details." So, i trying use date_modify() in setcontent = 'something' where {} but...
javascript,jquery,symfony2,twig,assetic
I'm a beginner developing a web app in Symfony2 and Twig for Google Chrome. I have read a lot of posts about how to add javascripts to a twig file like these: Where do Symfony2 shared CSS and JS assets go, best practice wise? Including stylesheets and Javascript to Twig...
symfony2,doctrine,twig
I'm using doctrine in my SYmfony2 project. I did a query that get all my project in a certain language, but it returns me all the language: public function rechercherProjets($lang, $cat) { return $qb = $this->createQueryBuilder('p') ->innerJoin ('p.descriptions', 'pi') ->innerJoin('p.categories', 'c') ->where('c.tag = :cat') ->andWhere('pi.langue = :lang') ->setParameters(array('lang'=>$lang,'cat'=>$cat)) ->getQuery()->getResult(); }...
php,html,arrays,symfony2,twig
I have a dynamic menu and in the top right corner I want to dinamically display the number of products I have in my cart. All my twigs extend base.html.twig in which I have this dynamic menu. <div id="mainBody" class="container"> <header id="header"> <div class="row"> <div class="span12"> <a href="index.html"><img src="{{ asset('bundles/mpshop/img/logo_title.png')...
symfony2,twig
I'm trying to achieve menu below but for some reason it doesn't show middle parts (level 2 and 3) of the menu if I navigate up to level 3 and 4. If I'm on level 3 then 1, 2, 3 should be visible. If I'm on level 4 then all...
php,symfony2,doctrine,entity,twig
I have the following setup: Entity: Customer Entity: Account Entity: Message Now imagine the following problem: The account 'Mark' is in charge of two customers, 'Ben' and 'Lili'. The account 'Tim' is in charge of two other customers, 'Tom' and 'Ronny'. The account 'Ben' now wants to send a message...
php,forms,symfony2,twig,symfony-forms
I'm using symfony 2.3 I have form with field of type "collection" Visualization code in twig: {% for field in form.fields %} {{ form_row(field.name) }} {% endfor %} Everything work, expect when form.fields is empty. Then nothing is visualized in twig loop, witch is fine. But at the end of...
php,html,symfony2,hex,twig
I try to secure email address on my website and I used the function (twig filter) below to encode it : /** * The twig filter associated with this function is "encode_email" */ function encode_emailFilter($email) { $text = $email; $text_encode = ''; for ($x=0; $x < strlen($text); $x++) { $text_encode...
javascript,symfony2,routing,twig
I installed FOSJsRouting but my route need _locale parameter. How can I do that in JS ? Is there a way to get the locale in js ? in twig, I can do app.request.attributes.get('_locale') but in JS, I don't find any documentation. AJAX $.ajax({ type : 'get', url : Routing.generate('get_credits',...
php,symfony2,twig,symfony-routing
I'm trying to create a special route that handles confirmation of a certain action. For instance, if I'm trying to access a route /admin/user/1/delete, I want to go to a different route first to show a special html page that confirms they want to complete an action (ie. confirm/admin/user/1/delete) and...
php,symfony2,doctrine2,twig
Edit: change findOneBy to findBy In symfony I am using the FOS-UserBundle. I have three tables. fos_user customer customer_user This is the customerUser.orm.xml <?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity...
css,symfony2,twig,assetic
I'm using Symfony with Twig and I use assetic. The problem is that my CSS file includes other CSS files like that: @import url(ie8.css); @import url(blocks.css); @import url(plugins.css); @import url(app.css); And these files are not found when webpage is displayed. Same happens with fonts and images. How do I solve...
php,arrays,magento,symfony2,twig
Id like to begin by saying that this shopping cart is not created by me, however it is changed in the way that I need and I understand most of the code and how it works and all the functions and methods are mine. The things I dont understand I...
php,symfony2,twig
Is it possible to get the name of the template that is calling a method in a twig extension? Example: private $templateInUse; public function __construct(){ $templateInUse = $this->someMagicalFunction(); } /** * {@inheritdoc} */ public function getName() { return 'twig_extension'; } public function getTokenParsers() { return array(new TokenParser($this->templateInUse)); } It would...
symfony2,include,twig,bootstrap
My Symfony application has a defaultBundle which loads a default.html.twig successfully. I am trying to include the contents of a navbar.html.twig into default.html.twig. The following code is my attempt to include the navbar code: {% block body %} {% include ('navbar.html.twig') %} <!-- this generates the error --> <div class='content'>...
symfony2,request,twig
I have a 404 error page set up through an event listener triggered by Kernel exceptions: public function onKernelException(GetResponseForExceptionEvent $event) { if ($event->isMasterRequest()) { $exception = $event->getException(); if ($exception instanceof NotFoundHttpException) { $response = new Response(); $event->setResponse( $response->setContent($this->templating->render( 'LandingPageBundle:Error:error404.html.twig', ['welcome_url' => $this->router->generate("welcome")] )) ); } } }...
symfony2,twig,twig-extension
I want to register my custom Twig filters in separate bundle (to avoid having one huge file). I have Yaml configurations in each bundle: # services.yml services: twig.extension.[BundleName]: class: Kuba\[BundleName]\Twig\AppExtension public: false tags: - { name: twig.extension } Yet, all the time the last (lexicographically) extension overrides previous one. How...
symfony2,twig
{% if ( session.get('userRole') != 'ROLE CLIENT USER' ) or ( session.get('actionPermission') == 'true' ) %} {# do stuff #} {% endif; %} ...
php,html,symfony2,twig
I do my first project in Symfony2. I have problem with template. My main twig file is "index.html.twig". It's located in src/Gogs/CMSBundle/Resources/views/Default/index.html.twig I try to extends main twig file from content.html.twig -> it's also in the same directory. In index.html.twig I have {% block body %}{% endblock %}. My content.html.twig...
php,twig,silex
I have just updated my dependencies for my Silex application and now suddenly one of my templates is failing with the error: Twig_Error_Syntax: The function "render" does not exist. This was working fine before I performed a composer update. From the composer output the following have been updated: - Removing...
symfony2,inheritance,twig
Following the example from the Symfony2 book, I have a three-level twig inheritance: app/Resources/views/base.html.twig blog/layout.html.twig blog/index.html.twig Whenever an X-fancyBox header is present in the request, I would like to omit the top node of the tree (base.html.twig). Is there any way of changing the inheritance tree from within an event...
php,twig,slim
I would like to send an array of flash messages to a twig template. The code would go like this: $errors = $validation->errors(); $app->flash('error', $errors); $app->response->redirect($app->urlFor('register'), 303); This is what I've tried in the twig template, but it doesn't render the messages: {% for error in flash.error %} {{ error...
php,symfony2,twig
I created a Twig extension, registered it in services, but im getting an error: This is the extension: <?php // src/AppBundle/Twig/AppExtension.php namespace Mp\ShopBundle\twig; class AppExtension extends \Twig_Extension { public function getFunctions() { return array( 'getTotalPrice' => new \Twig_Function_Method($this, 'getTotalPrice')); } public function getTotalPrice(Items $items) { $total = 0; foreach($items as...
php,mysql,mysqli,twig,accented-strings
This question already has an answer here: UTF-8 all the way through 14 answers I can query data from the database use mysqli, output to Twig and create a table, and words with characters with accents(À, Í, etc) are not displayed. The array can be displayed through a var_dump...
mysql,symfony2,doctrine,twig,silex
I have to get team members by their groups from a database. My Database looks like: table team_groups: id name table team_member: id name description imagepath team_group_id I have an twig template where the team_members are shown by there groups like this: <div class="row row-centered"> <h3 class="text-center">{{team_group.name}}</h3> <div class="col-xs-6 col-centered...
symfony2,date,twig
I'm trying to format a date and place each item (month, day and year) inside a div or span. I'm using a SaaS platform which provide a date like so: 2015-03-07 22:54:00 What I try to do is format this date into 3 separate items and place them in a...
php,twig
I have a variable name say var1 which has value value1 as string. How can i print the value of variable var1 where var1 is obtained as string To summarize it let {{ set container = 'var1' }} The value of the variable container is dynamic. Depending on the value...
twig,php-5.5
I have to work with an array of information extracted from a database and I want to display each part of this array according to a criterion, so it is better to make the test in the PHP or in the Twig template?
php,wordpress,post,twig,author
I'm using a wp template based on Twig files called Realia. I'm using to buddypress and I want to add a link button to the author profile of post. I found this page who help me a lot but I want to find the author name and what I found...
symfony2,many-to-many,twig
While editing I need to check the boxed that already have relation, I came up with this solution: {% for c in categories %} {% set checked = false %} {% for p in c.posts %} {% if p.id == post.id %} {% set checked = true %} {% endif...
symfony2,twig,haml
I wonder if theres a workaround to use twig combined with haml for symfony2 views. This is Haml http://haml.info/ (This is for Ruby On Rails) Basically is to use this: %section.container %h1= post.title %h2= post.subtitle .content = post.content instead of this: <section class=”container”> <h1><%= post.title %></h1> <h2><%= post.subtitle %></h2> <div...
php,symfony2,twig,formbuilder
I need to style each of radio button using Symfony form builder. This is my part of my createFormBuilder: ->add('categoryId', 'entity', array( 'class' => 'MyBundle:Category', 'property' => 'name', 'required' => false, 'expanded' => true )) And in my twig template: {% for child in form.categoryId %} <div class="radio i-checks col-md-3">...
javascript,jquery,symfony2,twig,markdown
I want to use Markdown to preview to the user how a form field on a twig file will be styled using javascript. Basically what I'm trying to do, is : // This function is used to show the Description Preview $( "#server_new_profile_description" ).on('input propertychange', function() { // This should...
php,symfony2,twig
Usual way of displaying select field is to call {{ form_row(form.doctor_service_id, {'attr':{'class':'form-control'}}) }} I would like to perform two things: Check if this field is actually a select field Iterate over every option (value, name). I know how twig iterator works, I just don't know how to access select options...
symfony2,sorting,twig
I'm trying to sort a list of categories in alphabetical order. Since this is more of a PHP flaw I'm trying to do this in a way which is described here. I really don't have access to the core files of the system so it need to be done with...
php,twig,twig-extension
I have a question, it's possible to make a in_array in twig template? For example I have an array call aColors with colors of one product : Array[ 0 => "1" 1 => "2" ] And I have a class in Libraries folder : class Colors{ public static $aColors =...
php,caching,twig
I have a template that looks like this ... {% if whatever %} <div>whatever<div> {% endif %} ... I setup my environement this way $twig = new \Twig_Environment( new \Twig_Loader_Filesystem( /template/path/ ['cache' => '/cache/path/'] ) ); $whatever = someFunctionFetchingFromDatabase(); $twig->addGlobal('whatever', $whatever); $twig->render('whatever'); Will the compilation cache reset whenever the $whatever...
php,symfony2,twig
Guys i have this problem when trying to "php app/console doctrine:schema:update --force" i don't know how to solve it(Unrecognized option "providers" under "security.providers.chain_provider") this is my security.yml security: role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] encoders: Setsuna\PrivateBundle\Entity\User: sha512 providers: in_memory: memory: ~ fr3d_ldapbundle: id: fr3d_ldap.security.user.provider fos_userbundle: id: fos_user.user_manager chain_provider: providers:...
symfony2,twig,symfony-2.6
In my symfony2 application I created a dashboard which currently consists of many navigation elements. Now I am trying to split those elements into several bundles. This is the code I have: {# app/Resources/views/base.html.twig #} {# ... #} {% block body %} {% endblock %} {# ... #} Then in...
symfony2,macros,twig,hierarchy
In my SF2 project I have an entity (Category) which I am representing in a hierarchical format with a parent at the top, followed by children, grandchildren etc. The Category entity has a getChildren method, which works and returns Category entity objects. I'm trying to work out a way to...
php,symfony2,doctrine,twig
I have multiple entities associated by ManyToMany and ManyToOne associations and I have problem with displaying data more than one level deep in to associations For example. There are 3 entities connected. Customer->Address->Country. In TWIG I can display: {{ customer.name }} // outputs name {{ customer.address.postcode }} // outputs post...
jquery,twig
I have such script $(document).ready(function () { var sum = 0; $('.price_jq').each(function () { var price = $(this); alert(price.html()); var count = price.parent().find('.count_jq'); alert(count.html()); sum = (price.html() * count.val()); $('.cart_total_price').append(sum + "₴"); }); }); My html <table> <td class="cart_price"> <p class="price_jq">{{ product.price }}</p> </td> <input size="2" name="count" value="2" class="count_jq" type="text"/>...
php,twig,router
I have decided to use Macaw Router Class for my simple projects, so just want to know How I can integrate Twig Template System with Macaw. Is there a way to do this?? Twig is running, macaw is running fine, But wen I try to do some thing like this,...