Я сделал форму веточки для поиска объектов моих миссий, у меня есть страница миссии, на которой указаны все миссии, и форма поиска не отображается вверху.
форма должна быть на вторая серая зона, начиная сверху.
репозиторий миссий
<?php
namespace App\Repository;
use App\Entity\Mission;
use App\Entity\MissionSearch;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Query;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\ORM\QueryBuilder;
/**
* @method Mission|null find($id, $lockMode = null, $lockVersion = null)
* @method Mission|null findOneBy(array $criteria, array $orderBy = null)
* @method Mission[] findAll()
* @method Mission[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MissionRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Mission::class);
}
/**
* @return Query
*/
public function findAllVisibleQuery(MissionSearch $search): Query
{
$query = $this->findVisibleQuery();
if ($search->getMaxGain()) {
$query = $query
->andWhere('m.gain <= :maxgain')
->setParameter('maxgain', $search->getMaxGain());
}
if ($search->getDeltaVille()) {
$query = $query
->andWhere('m.ville = :deltaville')
->setParameter('deltaville', $search->getDeltaVille());
}
return $query->getQuery();
}
/**
* @return Mission[]
*/
public function findLatest(): array
{
return $this->findVisibleQuery()
->setMaxResults(900)
->getQuery()
->getResult();
}
private function findVisibleQuery(): QueryBuilder
{
return $this->createQueryBuilder('m')
->where('m.Accepted = false');
}
// /**
// * @return Mission[] Returns an array of Mission objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('m')
->andWhere('m.exampleField = :val')
->setParameter('val', $value)
->orderBy('m.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Mission
{
return $this->createQueryBuilder('m')
->andWhere('m.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
шаблон веточки
{% extends 'base.html.twig' %}
{% block title 'Missions' %}
{% block body %}
<div class="jumbotron text-center">
<h1>Trouvez une mission qui vous correspond</h1>
<p>My super est encore en developpement , vous pouvez apporter vos idées via le formulaire de contact</p>
</div>
<div class="jumbotron text-center">
<div class="container">
{% if form is defined %}
{{ form_start(form) }}
<div class="form-row align-items-end">
<div class="col">
{{ form_row(form.maxGain) }}
</div>
<div class="col">
{{ form_row(form.deltaVille) }}
</div>
<div class="col">
<div class="form-group">
<button class="btn btn-primary">Rechercher</button>
</div>
</div>
</div>
{{ form_end(form) }}
{% endif %}
</div>
</div>
<div class="container">
<h2>Les dernieres missions</h2>
<div class="row flex">
{% for mission in missions %}
<div class="col-3">
<div class="card mb-4">
<div class="card-body">
<h5 class="card-title">
<a href="{{ path('mission.show', {id: mission.id, slug: mission.slug}) }}">{{ mission.titre }}</a>
</h5>
<p class="card-text">{{ mission.adresse }} {{ mission.ville }}</p>
<div class="text-primary" style="font-weight: bold;font-size: 2rem;">{{ mission.gain }} €</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
pagecontroller (missioncontroller)
<?php
namespace App\Controller;
use App\Repository\MissionRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\Mission;
class LesmissionsController extends AbstractController
{
/**
* @Route("/lesmissions", name="lesmissions")
* @param MissionRepository $repository
* @return Response
*/
public function index(MissionRepository $repository): Response
{
$missions = $repository->findLatest();
return $this->render('lesmissions/index.html.twig', [
'missions' => $missions
]);
}
}[![form supposed to be on the second greyzone starting from top][1]][1]
thanx заранее