CSS Conventions

Tags in forms generated by SQLFORM, SQLFORM.factory and CRUD follow a strict CSS naming convention that can be used to further customize the forms.

Given a table "mytable", a field "myfield" of type "string", it is rendered by default by a

1 SQLFORM.widgets.string.widget that looks like this:

1 <input type="text" name="myfield" id="mytable_myfield"

Notice that:

• the class of the INPUT tag is the same as the type of the field. This is very important for the jQuery code in "web2py_ajax.html" to work. It makes sure that you can only have numbers in "integer" and "double" fields, and that "time", "date" and "datetime" fields display the popup calendar.

• the id is the name of the class plus the name of the field, joined by one underscore. This allows you to uniquely refer to the field via j Query ( ' #mytable_myf ield' ) and manipulate, for example, the stylesheet of the field or bind actions associated to the field events (focus, blur, keyup, etc.).

• the name is, as you would expect, the field name.

+1 0

Average user rating: 5 stars out of 1 votes

Post a comment

  • Receive news updates via email from this site