I'm trying to create Symfony forms, and I want to use fontawesome icons inside the fields of symfony forms. In the twig config file i set the theme of bootstrap
I'm a beginner in symfony
I made a small example for my question:
that is my Controller Class:
<?php
namespace App\Controller;
use App\Form\UserType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class CreateUserController extends AbstractController
{
#[Route('/create-user', name: 'create_user')]
public function index(): Response
{
$user= array();
$form= $this->createForm(UserType::class, $user);
return $this->render('create_user/index.html.twig', [
'form' => $form->createView(),
]);
}
}
that is the UserType Class:
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class UserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class)
;
}
}
that is the twig template:
{{ form_start(form) }},
{{ form_widget(form) }}
{{ form_end(form) }}
the result of the current Code: See the screenshot [![enter image description here][1]][1]
What I want to be the field it's like this with font awesome icon:
[![enter image description here][2]][2]
Thank you very much [1]: https://i.stack.imgur.com/q5Zo1.png [2]: https://i.stack.imgur.com/rwCZ6.png