2012-05-24 53 views
0

只是想知道如何使用formbuilder在html樹枝中創建表單時可以從標籤中分離文本框?表單工作正常,但我想要對齊每個新的文本框和前面的文本,這樣看起來就不那麼草率了。有沒有一種方法可以渲染表單,然後設計它?我使用php來創建FormBuilder的表單,並用樹枝渲染。造型我的形式在樹枝&php

php的創建形式是這樣的:

$form = $this->createFormBuilder(array('csrf_protection' => false)) 
     ->add('username','text', array('label'=>'Username/Alias'))   
     ->add('password','password',array('label'=>'Password')) 
     ->add('ve','text',array('label'=>'Verification code')) 
     ->getForm() ; 
    $request= $this->getRequest(); 

而且樹枝看起來像這樣:

<form action="{{path('myBundle_login')}}" method="post" enctype={{form_enctype(form)}}> 
// the form_enctype(form) is the form that is sent through 

{{ form_errors(form) }} 

{{ form_widget(form) }} 

{{ form_rest(form) }} 

,但我只是希望它整齊地隔開......請幫助。

回答

1

,如果你想對所有形式的共同風格, 將共有的CSS像下面

form div label 
{ 
/*your css here*/ 
} 
form div input 
{ 
/*your css here*/ 
} 

和如果你想按照你的意願設計每一款

<div> 
    {{ form_errors(form.name) }}  
    <div> 
     <div> 
     {{ form_label(form.name) }} 
     </div> 
    </div> 

    <div> 
    <div> 
    {{ form_widget(form.name,{'attr': {'class': 'yourclassname'} }) }} 
    </div> 
    </div> 
    </div> 

這將整齊地分隔你的表格