I am a beginner with symfony and I have a problem bootstrap form themes.
app/config/config.yml
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form_themes:
- 'bootstrap_3_horizontal_layout.html.twig'
I have verified that it is four spaces identation.
My controller
<?php
namespace GR\SupervisorBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use GR\SupervisorBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;;
class SupervisorController extends Controller
{
public function indexAction()
{
return $this->render('GRSupervisorBundle:Supervisor:index.html.twig');
}
public function signInAction(Request $request)
{
//User creation
$user = new User();
//Connexion form creation
$formBuilder = $this->get('form.factory')->createBuilder(FormType::class, $user);
//Add entity fields to form
$formBuilder
->add('userName', TextType::class)
->add('password', PasswordType::class)
->add('signIn', SubmitType::class)
;
$form = $formBuilder->getForm();
return $this->render('GRSupervisorBundle:Supervisor:signIn.html.twig', array(
'form' => $form->createView(),
));
}
}
layout.html.twig
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{% block title %}Gornac.com{% endblock %}</title>
</head>
<body>
<!-- Body block -->
{% block body %} Hello World {% endblock %}
</body>
</html>
signIn.html.twig
{% extends "GRSupervisorBundle:Supervisor:layout.html.twig" %}
{% block title %}
Connexion - {{ parent() }}
{% endblock %}
{% block body %}
<h1> Connexion au superviseur </h1>
{{ include("GRSupervisorBundle:Supervisor:form.html.twig") }}
{% endblock %}
form.html.twig
<div class="well">
{{ form(form) }}
</div>
Result : screen
I followed this tutorial : https://openclassrooms.com/courses/developpez-votre-site-web-avec-le-framework-symfony/creer-des-formulaires-avec-symfony
And it doesn't work for me...
Thanks for help me
The easiest way integrate bootstrap see the official documentation:
here is the link: New in Symfony 3.4: Bootstrap 4 form theme
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.