I have a form which loads based on a lookup from the database of a id value from a get request.
$Id = $request->query->get('id');
if (!empty($Id) && $Id != 'add') {
$search = $this->getDoctrine()
->getRepository(Clients::class)
->find($Id);
if (is_null($search))
$this->addFlash('danger', 'Invalid Client');
else
$form = $this->createForm(ClientViewType::class,$search);
}
else {
$form = $this->createForm(ClientViewType::class);
}
You can see I'm adding a flashbag message of 'invalid client', but the problem is the form will still show. Is there some way to not show the form? Basically I just want the flashbag message to display and that's it.
I tried some things - i.e. setting $form to null, just returning the page, without the form, etc. but that just forces other problems.