Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3918

Injection of data in twig

$
0
0

This is the first time I come to ask for help. But here I dry and I can not find the answer to my problem anywhere.

I have just started working on the creation of a website under symfony 4. I am not yet well developed with this framework.

I have in my database a table: team that contains for each staff member:

-the name,

-first name,

-profession,

-particularité

-image of the person.

I can display all the information without any problem on the page. But what I am asked:

Display the image and information of a person on the same page in a square orange when clicking on the image corresponding to the person.

I hope to have been clear. I myself begin to lose myself in my head by dint of reflection.

my bug:
Controller "App\Controller\WhoController::index()" requires that you provide a value for the "$id" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.

<?phpnamespace App\Controller;use App\Entity\Equipe;use App\Repository\EquipeRepository;use Doctrine\Common\Persistence\ObjectManager;use Symfony\Component\Routing\Annotation\Route;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;class WhoController extends AbstractController{    /**     * @varEquipeRepository     */    private $repository;    /**     * @varObjectManager     */    private $em;    public function __construct(EquipeRepository $repository, objectManager $em)    {        $this->repository = $repository;        $this->em = $em;    }    /**     * @Route("/who", name="who")     * @paramEquipeRepository $repository     */    public function index($id, EquipeRepository $repository)    {        $equipes = $this->repository->findAllVisible();        //methode pour récupérer rapidement un enregistrement find        $equip = $this->repository->find($id);        return $this->render('pages/who.html.twig', ['equipes' =>$equipes,'equip' => $equip,'controller_name' => 'WhoController',        ]);    }
{% extends 'base.html.twig' %}{% block title %}Présentation{% endblock %}{% block body %}<div class="container-fluid"><div class="page-header text-center"><h2>L'équipe</h2></div><div class="space30"></div><div class="row">        {% for equipe in equip %}<div class="offset-2 col-8 offset-lg-2 col-lg-8 presentation"><div class="pres-image offset-2 col-4 offset-lg-2 col-lg-4"><img src="{{asset('build/placeholder200x250.jpg')}}"alt="affiche un membre de l'équipe" class="img-fluid"></div><div class="contenu offset-1 col-4 offset-lg-1 col-lg-4"><p class="pres-nom">Nom: {{ equip.nom }}</p><p class="pres-prenom">Prenom:{{ equip.prenom }}</p><p class="pres-profession">Profession:{{ equip.profession }}</p><p class="pres-custom">Particularité: {{ equip.custom }}</p></div></div>        {% endfor %}</div><div class="row">        {% for equipe in equipes %}<div class="col-4 col-lg-3"><div class="card-body text-center">                    {% if equipe.imageName %}<a href="{{ path('show',{ id:equipe.id }) }}"><img src="{{ vich_uploader_asset(equipe, 'imageFile')| imagine_filter('avatar') }}" alt="card-img-top" class="img-fluid"></a>                    {% endif %}<div class="card-footer text-center"><h5>{{ equipe.nom }}</h5><h5>{{ equipe.prenom }}</h5></div></div></div>        {% endfor %}</div>{{ include ('pages/_footer.html.twig') }}</div>{% endblock %}

Viewing all articles
Browse latest Browse all 3918

Trending Articles