After updating from Symfony 3.4 to 4.4 and verifying the operation, I found that app_hq_article_trendtag
in input.html.twig refers to another page.The reference destination was B of ArticleController. As of Symfony 3.4, it worked fine. Did you make a mistake in the settings? If there is something else to check other than the command please tell me.
I also changed some code and checked the operation. Change @Template("@AppBundle/Hq/Article/index.html.twig")
of ArticleController to another page-> Another page is displayed. Change @Template("@AppBundle/Hq/Article/trendTag.html.twig")
of ArticleController to another page-> No change Change app_hq_article_trendtag
of input.html.twig to another page-> Another page is displayed.
ArticleController
* @Route("/hq")
*/
class ArticleController extends BaseArticleController
{
protected $indexRoute = "app_hq_article_index";
protected function getInputTemplate($articleType)
{
return sprintf("@AppBundle/Hq/%s/input.html.twig", ucfirst($articleType));
}
/**
* @Method("GET")
* @Route("/article/")
*
* @Template("@AppBundle/Hq/Article/index.html.twig")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
/**
* @Method("GET")
* @Route("/article/trendtag")
*
* @Template("@AppBundle/Hq/Article/trendTag.html.twig")
*/
public function trendTagAction(Request $request)
{
return parent::trendTagAction($request);
}
Brandevent/input.html.twig
{{ form_start(form) }}
<div class="formGroup trendTags" data-prototype="{{ macros.trendTagForm(form.trendTags.vars.prototype)|e }}" data-index="{{ ec_tag_contents|length }}">
<label>Tag</label>
<button type="button" class="add btn">Add</button>
<ul class="trend-tag-list2" {% if not ec_tag_contents|default %} style="display:none"{% endif %} id="trendTagsWrap">
{% for tag in ec_tag_contents|default %}
<li>
<div class="tagForm">
<div class="input-trendtag-display-name"> {{ tag.name }}</div>
<div class="input-trendtag-display-term">({{ tag.str_tag_display }} {{ tag.str_term }})</div>
<br>
{% for category in tag.categories|split(',') %}
<div class="tag-form__category-sticker" name="{{ category }}">{{ category }}</div>
{% endfor %}
<button class="removeTrendTag"><i class="icon-remove"></i></button>
</div>
<div id="brandevent_trendTags_{{ loop.index0 }}">
<input type="hidden" id="brandevent_trendTags_{{ loop.index0 }}_trendTagId" name="brandevent[trendTags][{{ loop.index0 }}][trendTagId]" required="required" value="{{ tag.tag_id }}">
</div>
</li>
{% endfor %}
{% do form.trendTags.setRendered(true) %}
</ul>
</div>
{{ form_end(form) }}
//Problem part
{% set q = app.request.query.get("q")|default({}) %}
{% set trendTagUrl = path("app_hq_article_trendtag", {"q[sex]": q.sex|default(0), "q[brand_id]": q.brand_id|default(), "q[del_flg]": 0}) %}
<div id="trendTagDialog" title="Tag Select" data-url="{{ trendTagUrl }}">
</div>
Command
$ php bin/console debug:router app_hq_article_trendtag
+--------------+--------------------------------------------------------------------+
| Property | Value |
+--------------+--------------------------------------------------------------------+
| Route Name | app_hq_article_trendtag |
| Path | /admin/hq/article/trendtag |
| Path Regex | #^/admin/hq/article/trendtag$#sD |
| Host | ANY |
| Host Regex | |
| Scheme | http |
| Method | ANY |
| Requirements | NO CUSTOM |
| Class | Symfony\Component\Routing\Route |
| Defaults | _controller: AppBundle:Hq\Article:trendTag |
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
| Callable | AppBundle\Controller\Hq\ArticleController::trendTagAction |
+--------------+--------------------------------------------------------------------+
If you change the order of the functions will work fine when you try to get Route /hq/article/trendtag,it will get the first /hq/article that find it,so you can change it like the code below the file is being read from the top, when it finds the route "/article/" before /article/trendtag
even if you want to get /article/trendtag
, he only considers the /article/
first part that found it.
* @Route("/hq")
*/
class ArticleController extends BaseArticleController
{
protected $indexRoute = "app_hq_article_index";
protected function getInputTemplate($articleType)
{
return sprintf("@AppBundle/Hq/%s/input.html.twig", ucfirst($articleType));
}
/**
* @Method("GET")
* @Route("/article/trendtag")
*
* @Template("@AppBundle/Hq/Article/trendTag.html.twig")
*/
public function trendTagAction(Request $request)
{
return parent::trendTagAction($request);
}
/**
* @Method("GET")
* @Route("/article/")
*
* @Template("@AppBundle/Hq/Article/index.html.twig")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.