Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The big thing about forms is that all form controls, including input, text area, and select element, are set to 100 width by default. So you can see the difference right here. You'll see that this field takes up the whole width of the container, whereas in the old version of Bootstrap, it would just default to a certain width. That's certainly more mobile friendly, so that's a great upgrade. Something you'll have to watch out for is that because all widths default to 100%, to use inline forms, you'll have to set the width of the form controls manually. One of the cool features of Bootstrap is the ability to create horizontal forms. Where the labels and fields are side by side.
In the new Bootstrap, this is treated like any other layout, so you create a form with a class of form-horizontal, and then you use the col, col-lg, and then a number, just like this right here. Now this is different than the old version of Bootstrap, where you used to create a series of control groups. This makes a lot more sense now but it's definitely different than before so it means that you should check the forms on your old Bootstrap website if you're upgrading. One thing that you'll notice throughout the Bootstrap upgrade is a series of warnings like this one right here. This one tells you, for example, that inputs will only be fully styled if they're type attribute is properly declared.
Now that used to be true of the old version of Bootstrap, but there was no warning, so you sort of found out about these kind of problems by trial and error, so it's nice to see them available by default on the documentation. Something else that changes is checkboxes and radio buttons. In the old version of Bootstrap, you used to define checkboxes by adding a check box class to your labels and wrapping your input fields. It's a bit different in the new version, you still wrap your input fields but you also wrap another separate div with the check box class. Inlining forms is also a bit different. Instead of two classes for checkbox and inline, you use a separate checkbox inline and checkbox radio class.
You can now disable not just an individual control, but also an entire field set. You have to be careful because this won't work in IE or Safari. The rest of the form changes in this section are pretty much the same things applied to other elements. Classes have been simplified and hyphenated, layouts are done with columns, and classes have been renamed. If you've been using a lot of the functionality in forms, you'll be doing a lot of updating when you upgrade.
Get unlimited access to all courses for just $25/month.Become a member