0

エンティティに CRUD ジェネレーターを使用してから、テンプレート AdminLTE を統合しました。できます; 今、小枝ファイルの表示を設定しようとしましたnew.html.twigファイル(フォーム)から始めます 基本テンプレートのレイアウトに従います

new.html.twig

{% extends 'base.html.twig' %}
{% block body  %}
    <h1>User creation</h1>

    {{ form_start(form) }}
        {{ form_widget(form) }}
        <input type="submit" value="Create" />
    {{ form_end(form) }}

    <ul>
        <li>
            <a href="{{ path('user_index') }}">Back to the list</a>
        </li>
    </ul>   
{% endblock %}

index.html.twig

{% extends 'base.html.twig' %}
{% block body  %}    
    <h1>User list</h1>

    <table>
        <thead>
            <tr>
                <th>Id</th>
                <th>Name</th>
                <th>Lastname</th>
                <th>Gender</th>
                <th>Birthday</th>
                <th>Birthplace</th>
                <th>Email</th>
                <th>Phonenumber</th>
                <th>Grade</th>
                <th>Profile</th>
                <th>Documentid</th>
                <th>Photoid</th>
                <th>Directeur</th>
                <th>Codirecteur</th>
                <th>Effectue</th>
                <th>Mediaid</th>
                <th>Created</th>
                <th>Updated</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
        {% for user in users %}
            <tr>
                <td><a href="{{ path('user_show', { 'id': user.id }) }}">{{ user.id }}</a></td>
                <td>{{  user.name }}</td>
                <td>{{  user.lastName }}</td>
                <td>{{ user.gender }}</td>
                <td>{% if user.birthday %}{{ user.birthday|date('Y-m-d') }}{% endif %}</td>
                <td>{{ user.birthPlace }}</td>
                <td>{{ user.email }}</td>
                <td>{{ user.phoneNumber }}</td>
                <td>{{ user.grade }}</td>
                <td>{{ user.profile }}</td>
                <td>{{ user.documentId }}</td>
                <td>{{ user.photoId }}</td>
                <td>{% if user.directeur %}Yes{% else %}No{% endif %}</td>
                <td>{% if user.coDirecteur %}Yes{% else %}No{% endif %}</td>
                <td>{% if user.effectue %}Yes{% else %}No{% endif %}</td>
                <td>{{ user.mediaId }}</td>
                <td>{% if user.created %}{{ user.created|date('Y-m-d H:i:s') }}{% endif %}</td>
                <td>{% if user.updated %}{{ user.updated|date('Y-m-d H:i:s') }}{% endif %}</td>
                <td>
                    <ul>
                        <li>
                            <a href="{{ path('user_show', { 'id': user.id }) }}">show</a>
                        </li>
                        <li>
                            <a href="{{ path('user_edit', { 'id': user.id }) }}">edit</a>
                        </li>
                    </ul>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

    <ul>
        <li>
            <a href="{{ path('user_new') }}">Create a new entry</a>
        </li>
    </ul>
{% endblock %}

config.yml

#Twig Configuration twig: 
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form_themes: - user:new.html.twig

config.yml に触れる前に、ディスプレイを添付しました。

ここに画像の説明を入力

4

1 に答える 1

0

あなたの質問はかなり漠然としていますが、私は問題を見ていると思います。

AdminLTE テンプレートを Symfony3 に統合したい場合、base.html.twig(他のすべてのテンプレートが拡張される) を必要な HTML と CSS で既に更新していますが、フォーム要素が正しく表示されません (提供されたスクリーンショットを参照)。

次のいずれかの方法を使用して、デフォルトですべてのフォームをブートストラップ スタイルでレンダリングするように Symfony に指示できます。


アプリケーションワイド

これにより、ブートストラップ クラスが適用されたすべての小枝フォームがレンダリングされます。

を更新してapp/config/config.yml、以下を含めます。

# app/config/config.yml
twig:
    form:
        # All forms will use the `vertical` bootstrap form layout
        resources: ['bootstrap_3_layout.html.twig']

        # All forms will use the `horizontal` layout
        # resources: ['bootstrap_3_horizontal_layout.html.twig']

フォーム固有

以下を使用して、単一の小枝フォームにスタイルを適用できます。とフォームのテーマを受け入れるタグに
注意してください。form_themeform

{% extends 'base.html.twig' %}
{% block body  %}
    <h1>User creation form</h1>

    {# {% form_theme form 'bootstrap_3_horizontal_layout.html.twig' %} #}

    {% form_theme form 'bootstrap_3_layout.html.twig' %}
    {{ form_start(form) }}
        {{ form_widget(form) }}
        <input type="submit" value="Create" />
    {{ form_end(form) }}
{% endblock %}

AdminLTE Symfony Bootstrap フォームの統合


Symfony のドキュメントでは、フォームのカスタマイズについて詳しく説明しています。

于 2016-08-20T15:13:56.473 に答える