twig

“While” and “repeat” loops in Twig

与世无争的帅哥 提交于 2020-05-14 15:56:22
问题 Are there any nice ways to use while and repeat loops in Twig? It is such a simple task, but without macros I can't find anything nice and simple. At least do an infinite cycle and then break it in a condition? EDIT: I mean something like do { // loop code } while (condition) or while (condition) { // loop code } Edit 2: Looks like it is not supported natively by twig same reason as it is not supported neither continue; or break; statements. https://github.com/twigphp/Twig/issues/654 回答1: In

How to store and retrieve materializecss chips?

邮差的信 提交于 2020-04-30 15:13:50
问题 I have a form where I'm putting the chipsData into a hidden input field called #hiddenTags I'm doing this because I don't want you use an AJAX call because I have a pre-exist form. Below is how I'm putting the chip data into the hidden input. $("form").on("submit", function() { var tags = M.Chips.getInstance($('.chips')).chipsData; var sendTags = JSON.stringify(tags); $('#hiddenTags').val( sendTags ); }); I'm sending it to the database like this: (PHP) $this->tags = json_encode( $data['tags']

symfony 3.4 pass variable to a modal in twig

邮差的信 提交于 2020-04-14 08:53:30
问题 I need help to solve my problem. I have a page with my list of "equipos". Every "equipo" in the table has an Edit buttom, and the page show another buttom to add new "equipos". So far I manage to call a modal for NEW using the {{ render() }} syntax, the equipoNewModal works fine because is an "static" route (/equipo/new) in Symfony; but the EDIT don't work because I can't pass the "equipo" variable to the equipoEditModal and get the id to complete the route ( /equipo/{id}/edit ) and call the

Integrating twig with react.js

元气小坏坏 提交于 2020-04-11 17:22:32
问题 I have successfully built a webapp with php symphony and its twig template system, but now requirement has changed, and I have to make use of node react.js. I have read a handful of documentation on react.js but I am still lost on the best approach for my strict timeframe. Any help on how I can do this safely and quickly is appreciated, even in advanced. How can someone implement react.js in a template like this? {% extends 'admin/base.html.twig' %} {% block content %} Fill This form {{ form

Integrating twig with react.js

南笙酒味 提交于 2020-04-11 17:21:30
问题 I have successfully built a webapp with php symphony and its twig template system, but now requirement has changed, and I have to make use of node react.js. I have read a handful of documentation on react.js but I am still lost on the best approach for my strict timeframe. Any help on how I can do this safely and quickly is appreciated, even in advanced. How can someone implement react.js in a template like this? {% extends 'admin/base.html.twig' %} {% block content %} Fill This form {{ form

Displaying value from the “ps_product” table in a twig file in prestashop 1.7.5

夙愿已清 提交于 2020-03-16 11:20:11
问题 I'm currently migrating an old shop in which the fields isDirect and isMotor already exist in the ps_product table. I added these two fields in the ps_product table of the new shop. These two fields are tinyint type, and their value is 0 or 1 . Here is my Product class : public $isMotor; public $isDirect; with following data-structure: 'isMotor' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'isDirect' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), Then when I try

Displaying value from the “ps_product” table in a twig file in prestashop 1.7.5

99封情书 提交于 2020-03-16 11:19:19
问题 I'm currently migrating an old shop in which the fields isDirect and isMotor already exist in the ps_product table. I added these two fields in the ps_product table of the new shop. These two fields are tinyint type, and their value is 0 or 1 . Here is my Product class : public $isMotor; public $isDirect; with following data-structure: 'isMotor' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'isDirect' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), Then when I try

Displaying value from the “ps_product” table in a twig file in prestashop 1.7.5

﹥>﹥吖頭↗ 提交于 2020-03-16 11:19:11
问题 I'm currently migrating an old shop in which the fields isDirect and isMotor already exist in the ps_product table. I added these two fields in the ps_product table of the new shop. These two fields are tinyint type, and their value is 0 or 1 . Here is my Product class : public $isMotor; public $isDirect; with following data-structure: 'isMotor' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'isDirect' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), Then when I try

Impossible to access an attribute (“name”) on a string variable (“1”)

孤者浪人 提交于 2020-03-03 09:06:11
问题 How can I get the name and not just the id? This what actually I have in the datatable: Current Datatable But what I nedd is show the name of the area NOT the id. I tried to do this: <table aria-describedby="dataTable_info" cellspacing="0" class="table table-hover dataTable" id="dataTable" role="grid" style="width:100%;" width="100%"> <thead> <tr> <th>Areas</th> <th>Auditorias</th> </tr> </thead> <tbody> {% for audit in auditsByArea %} <tr> <td>{{ audit.id_Area.name }}</td> <td>{{ audit

Symfony2 : Why getToken return null when injecting SecurityContext in a TwigExtension?

孤街浪徒 提交于 2020-02-24 00:50:35
问题 I did exactly the answer from this post but the token property is null and the user is correctly logged in and the route is behind a firewall. Also, I am injecting the SecurityContext in other services and it works fine. services.xml : <service id="tc.extensions.relation_helper" class="TC\CoreBundle\Extensions\RelationHelperExtension"> <argument type="service" id="security.context" /> <tag name="twig.extension" /> </service> My extension: class RelationHelperExtension extends Twig_Extension {