Some mandatory parameters are missing
Bonjour,
je suis entrain de tester un moteur de recherche et vu que je débute avec symfony j'ai eu cette erreur:
"Some mandatory parameters are missing ("publishedAt") to generate a URL for route "obtao-article-search". " que je pense une mal configuration de rounting.yml
le contorleur:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
public function listAction(Request $request)
{
$articleSearch = new ArticleSearch();
$articleSearchForm = $this->get('form.factory')
->createNamed(
'',
'article_search_type',
$articleSearch,
array(
'action' => $this->generateUrl('obtao-article-search'),
'method' => 'GET'
)
);
$articleSearchForm->handleRequest($request);
$articleSearch = $articleSearchForm->getData();
$elasticaManager = $this->container->get('fos_elastica.manager');
$results = $elasticaManager->getRepository('ObtaoBlogBundle:Artic')->search($articleSearch);
return $this->render('ObtaoBlogBundle:Article:list.html.twig',array(
'results' => $results,
'articleSearchForm' => $articleSearchForm->createView(),
));
} |
le rounting:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
obtao_blog_homepage:
pattern: /hello/{name}
defaults: { _controller: ObtaoBlogBundle:Default:index }
obtao-article-search:
pattern: /list/{title}
defaults: { _controller:ObtaoBlogBundle:Article:list }
requirements:
_method: GET
obtao-article-search:
pattern: /list/{content}
defaults: { _controller:ObtaoBlogBundle:Article:list }
requirements:
_method: GET
obtao-article-search:
pattern: /list/{isPublished}
defaults: { _controller:ObtaoBlogBundle:Article:list }
requirements:
_method: GET
obtao-article-search:
pattern: /list/{publishedAt}
defaults: { _controller:ObtaoBlogBundle:Article:list }
requirements:
_method: GET |
list.twig.html
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
{% extends 'ObtaoBlogBundle::layout.html.twig' %}
{% block body %}
<h1>List of articles</h1>
<h2>Filter</h2>
<div class="row">
<div class="col-md-5">
{{ form(articleSearchForm) }}
</div>
</div>
<h2>Results ({{ results|length }})</h2>
<ul>
{% for article in results %}
<li>
<h3>{{ artic.title }}</h3>
<p>{{ artic.content }}</p>
<p>
<strong>Status : </strong>
{% if artic.isPublished %}
Published on {{ artic.publishedAt|date('m/d/Y') }}
{% else %}
Not published yet
{% endif %}
</p>
</li>
{% else %}
<li>No result for this search</li>
{% endfor %}
</ul>
{% endblock %} |
j'espère avoir un réponse le plus tôt possible ,merci d'avance :)