Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap: form-horizontal not styling as expected

I am using twitter bootstrap and would like to have a horizontal form as shown in the demo here: http://twitter.github.com/bootstrap/base-css.html#forms

However, I get a kind of vertical form I guess with labels over control, I can't find why the vertical form styling isn't working.

Here is the html code (generated with symfony2 framework:

<form class="form-horizontal" method="POST" action="/yourownpoet/web/app_dev.php/register/">
    <label class=" required" for="fos_user_registration_form_email" placeholder="Email">Email:</label>
    <input id="fos_user_registration_form_email" class="text-style" type="email" placeholder="Email" required="required" name="fos_user_registration_form[email]">
    <div placeholder="Password" id="fos_user_registration_form_plainPassword">    <div>
        <label class=" required" for="fos_user_registration_form_plainPassword_Enter Password: ">Enter password: </label>
        <input type="password" required="required" name="fos_user_registration_form[plainPassword][Enter Password: ]" id="fos_user_registration_form_plainPassword_Enter Password: " class="text-style">
    </div>
  <div>
      <label class=" required" for="fos_user_registration_form_plainPassword_Verify Password: ">Verify password: </label>
    <input type="password" required="required" name="fos_user_registration_form[plainPassword][Verify Password: ]" id="fos_user_registration_form_plainPassword_Verify Password: " class="text-style">
 </div>
   etc...
</form>

Is there something I am doing wrong?

like image 402
fkoessler Avatar asked Jul 12 '12 08:07

fkoessler


1 Answers

You need to apply the .control-label class to your labels and separate your inputs inside a .controls container for your form styles to apply correctly. Try this instead:

<form class="form-horizontal" method="POST" action="/yourownpoet/web/app_dev.php/register/">
    <div class="control-group">
        <label class="control-label required" for="fos_user_registration_form_email" placeholder="Email">Email:</label>
        <div class="controls">
            <input id="fos_user_registration_form_email" class="text-style" type="email" placeholder="Email" required="required" name="fos_user_registration_form[email]">
            <div placeholder="Password" id="fos_user_registration_form_plainPassword"></div>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label required" for="fos_user_registration_form_plainPassword_Enter Password: ">Enter password: </label>
        <div class="controls">
            <input type="password" required="required" name="fos_user_registration_form[plainPassword][Enter Password: ]" id="fos_user_registration_form_plainPassword_Enter Password: " class="text-style">
        </div>
    </div>
    <div class="control-group">
        <label class="control-label required" for="fos_user_registration_form_plainPassword_Verify Password: ">Verify password: </label>
        <div class="controls">
            <input type="password" required="required" name="fos_user_registration_form[plainPassword][Verify Password: ]" id="fos_user_registration_form_plainPassword_Verify Password: " class="text-style">
        </div>
    </div>
</form>
like image 141
Andres Ilich Avatar answered Oct 13 '22 13:10

Andres Ilich