Loading...
 

History: Bootstrap Transition - Forms

Preview of version: 18

There are many forms in Tiki's Smarty template files, and generally these need to be modernized and made Bootstrap-compatible (and therefore responsive - more usable in all device sizes).

Although the construction of some admin pages, etc. was updated, the templates directory still (as of Dec. 8, 2013) contains 218 usages of table class="formcolor", which as a rule has been used for form layout in Tiki. So the task continues.

For example, code like:

<form>
<table class="formcolor" width="100%">
	<tr>
		<td><label for="anonymous_name">Name</label></td>
		<td><input type="text" maxlength="50" size="30" 
id="anonymous_name" name="anonymous_name"  value="{$comment_preview_data.name|escape}"></td>
	</tr>
</table>
</form>


Needs to be changed to something like:

<form class="form-horizontal" role="form">
  <div class="form-group">
    <label for="anonymous_name" class="col-sm-2 control-label">Name</label>
    <div class="col-sm-10">
      <input type="text" maxlength="50" class="form-control" 
id="anonymous_name" name="anonymous_name"  value="{$comment_preview_data.name|escape}">
    </div>
  </div>
</form>


Class="form-horizontal" uses Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout. Class="form-group" groups a label and input and gives them some bottom white space. Class="control-label" gives the label some spacing and aligns the text to the right. Class="form-control" adds styling to the input and makes its width 100%. The width can be controlled by wrapping the div in one of the grid-class divs, if needed.

Form construction style guide needed

Other general practices will follow, here. We should have a guide so any forms added in the future can be made the same way and have a unified appearance.

One problem so far: form-horizontal class is missing.

Many of Tiki's converted forms that are "form-horizontal" type according to Bootstrap docs don't have that class. The wiki edit page and some other content-creating/editing pages have class form-horizontal, but most tiki-admin.php?page=x forms don't. The visual difference is that with form-horizontal, field labels are aligned right, to be close to the field. This is considered best practice for UI. Without form-horizontal, the labels are aligned left, which makes for a visually nice even left margin, but worsens UI since the user has to try harder to match each label and its field.

In the following, the label and selector or textarea are contained in grid classes for appropriate layout.

Select

<div class="form-group">
     <label class="col-sm-2 control-label" for="mess-prio">Priority:</label>
     <div class="col-sm-10">
          <select name="priority" id="mess-prio" class="form-control">
     </div>
</div>

Similarly, for

Textarea

<div class="form-group">
     <label class="col-sm-2 control-label" for="broadcast-body">Body:</label>
     <div class="col-sm-10">
          <textarea class="form-control" rows="20" name="broadcast-body" id="broadcast-body" />
    </div>
</div>

Form input style


Question as of 2014-01-25: two directions emerged in the recent bootstrap transition for styling of input fields, can we/should we pick one in order to have a standardized layout?

Option 1: label is above the input field

Sample:
Edit Article Sample

Pro: label length does not matter, also translations can be as long as desired without linebreaks

sample for long label:
Edit Article Sample Longlabel

Contra: form becomces longer vertically as each label is a new row

Option 2: label is before the input field

Sample:
Edit Blog Sample

Pro: form is shorter vertically

Contra: if the label text or the translation is long, than the input filed has less space, also layout becomes messy as the label text/description get linebreaks to fit into the allowed space, so the form becomes long again..

Tiki Trunk NewTest 2014 01 28 15 23 15 (Vertical Labels)

Opinions


gezza: i am for option1.

update: Tiki has many options for each feature and I agree it makes the editing layout too long and scattered. Having labels on the left is ok for "small" inputs, eg language selection, but for larger text areas (eg: body of a blog post or an article) having the label above is nicer as it leaves more space for the content.
I think the key is the content, the focus should alway be on the content.

Maybe an approach could be to have a different layout for content, eg: have Content tab where labels are above and all other tabs that are for settings the labels are on the left.

Or is it too comlicated and hard to follow?

Voting might be useful to achieve a general understanding

luci: +1 for option1, also for removing the need to use "for" attribute and id="" on these labels+inputs (prevent breakage of things when you get accidentally two forms with same IDs on one page), something like this (notice how the label contains the form input element; would be possible ?):

<div class="form-group"> <label class="col-sm-12 control-label"><span>Priority:</span> <select name="priority" class="form-control"> </label> </div>


gary: luci, I like the simpler way you describe, of wrapping the input or select with the label tags, but it doesn't seem to be supported very well in Bootstrap (see http://getbootstrap.com/css/#forms). I get not-so-good results when I try that.

About the choice of label position - above the input or on the left side, I followed the legacy layout pretty much, as shown on tiki-admin pages. This also seems to be the most common on the web (anyway, according to http://www.uxmatters.com/mt/archives/2006/07/label-placement-in-forms.php). I kind of prefer to have the labels on the left, as the page content seems more clear to me, but this is probably a matter of opinion. I didn't check about label length problems in translated strings. I (ignorantly) used the English string lengths to decide about the grid size. This could be adjusted if there is a frequent problem with too much text wrapping. Here are two versions of tiki-editpage.tpl's Properties tab content (not optimized, but just for a quick comparison):

Tiki Trunk NewTest 2014 01 28 15 23 15 (Vertical Labels)
Tiki Trunk NewTest 2014 01 28 15 27 44 (Labels On Left)

Do we need to have a "vote" or something to decide label position?









History

Advanced
Information Version
Wed 05 of Aug, 2015 09:40 GMT chibaguy 26
Wed 05 of Aug, 2015 09:26 GMT chibaguy Breakpoint display size item added. 25
Wed 05 of Aug, 2015 07:33 GMT chibaguy 24
Wed 05 of Aug, 2015 07:03 GMT chibaguy 23
Wed 05 of Aug, 2015 07:01 GMT chibaguy 22
Wed 05 of Aug, 2015 06:52 GMT chibaguy 21
Thu 30 of Jul, 2015 07:03 GMT gezza extending with breakpoint notes 20
Thu 30 of Jul, 2015 07:01 GMT gezza notes about various label sizes 19
Thu 30 of Jul, 2015 06:00 GMT chibaguy 18
Tue 28 of Jan, 2014 10:22 GMT gezza opinion update 17
Tue 28 of Jan, 2014 06:49 GMT chibaguy popup images removed - not useful. 16
Tue 28 of Jan, 2014 06:47 GMT chibaguy Bad copy/paste removed. 15
Tue 28 of Jan, 2014 06:41 GMT chibaguy 14
Tue 28 of Jan, 2014 06:39 GMT chibaguy 13
Sat 25 of Jan, 2014 13:20 GMT luci 12
Sat 25 of Jan, 2014 12:23 GMT gezza 11
Sat 25 of Jan, 2014 12:22 GMT gezza 10
Sat 25 of Jan, 2014 12:19 GMT gezza form input layout options 9
Sun 08 of Dec, 2013 12:54 GMT chibaguy Code corrected. 8
Sun 08 of Dec, 2013 12:52 GMT chibaguy Textarea added. 7
Sun 08 of Dec, 2013 12:46 GMT chibaguy Select layout added. 6
Sun 08 of Dec, 2013 03:47 GMT chibaguy 5
Sun 08 of Dec, 2013 03:46 GMT chibaguy 4
Sun 08 of Dec, 2013 03:45 GMT chibaguy 3
Sun 08 of Dec, 2013 03:43 GMT chibaguy 2
Sun 08 of Dec, 2013 03:42 GMT chibaguy Page created. 1

Switch Theme

Layout

Latest Changes

No records to display ...more

Subscribe to Tiki Newsletters!

Delivered fresh to your email inbox!
Newsletter subscribe icon
Don't miss major announcements and other big news!
Contribute to Tiki

Site Config