Symfony 3.3:Bootstrap表单主题不起作用

时间:2017-10-22 15:32:17

标签: php symfony twig

我是symfony的初学者,我有一个问题引导程序表单主题。

应用程序/配置/ config.yml


    if ("request_response".equals(type)) {

        sendNotification("You have a response to your request", "Response Available", HomeActivity.class);

                    if (!BaseApp.isActivityVisible()){

                        sendNotification("You have a response to your request", "Response Available", HomeActivity.class);

                    } else {
    //process data
    }

我已经确认它是四个空格标识。

我的控制器

<?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>

结果:screen

我遵循了这个教程: https://openclassrooms.com/courses/developpez-votre-site-web-avec-le-framework-symfony/creer-des-formulaires-avec-symfony

它对我不起作用......

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

集成bootstrap的最简单方法请参阅官方文档:

这是链接:New in Symfony 3.4: Bootstrap 4 form theme