2015-05-10 70 views
1

我最近的問題和答案後(這是運作良好),我已經創建了自己的模板:添加新的資源目錄到config.yml

{% extends "bootstrap_3_layout.html.twig" %} 
{% block choice_widget_collapsed -%} 
    {% set attr = attr|merge({class: (attr.class|default('') ~ ' combobox input-large form-control')|trim}) %} 
    {{- parent() -}} 
{%- endblock %} 

首先,它是目錄下...

..\vendor\symfony\symfony\src\Symfony\Bridge\Twig\Resources\views\Form\form_combo_layout.html.twig 

然而,因爲有喜歡的一個,我從引導擴展其他模板,我沒有想我「與原來的引導模板combobox'component覆蓋,因爲他們使用的是

0123完全相同的文件夾路徑

,並沒有就當我打電話的config.yml沒有問題... ...

twig: 
    debug:   "%kernel.debug%" 
    strict_variables: "%kernel.debug%" 
    form_themes: ['Form/form_errors.html.twig'] 
    form:     
     resources: ['form_combo_layout.html.twig'] 

然而,由於類似的組件的首要的我投入到不同的文件下的「資源」,這是

..\vendor\symfony\symfony\src\Symfony\Bridge\Twig\Resources\templates\form_combo_layout.html.twig 

,並取決於我想修改我在config.yml作爲路徑...

twig: 
    debug:   "%kernel.debug%" 
    strict_variables: "%kernel.debug%" 
    form_themes: ['Form/form_errors.html.twig'] 
    form: 
     resources: ['../Resources/templates/form_combo_layout.html.twig'] 

在最後...我面臨着相關網頁,其中爲localhost錯誤...

Unable to find template "../Resources/templates/form_combo_layout.html.twig" in base.html.twig at line 23. 
500 Internal Server Error - Twig_Error_Loader 
1 linked Exception: RuntimeException » 

Eventhough,文件的路徑和文件是否存在。

一些bulleye幫助將不勝感激!

PS:這是寫在食譜,我們不能使用參數進口建立動態路徑..

imports: 
    - { resource: "%kernel.root_dir%/parameters.yml" } 

這是錯誤的

回答

0

我找到解決方案,它是很容易像地獄.... 由於資源路徑請求具有「目錄路徑」參數的數組形式,它應該是

resources: ['templates/form_combo_layout.html.twig']