I am currently using this for my new user form:
class UserForm(AdminPage):
entity = Model.User
title = 'User'
class child(ListForm):
css_class = 'form-horizontal'
buttons = [SaveButton(),CancelButton()]
...
phone = TextField(
label = 'Phone',
validator = twc.Required
)
...
I am assuming that I will have to use something else than a ListForm to do what I want. Here is what I need:
I would like to customize the length of certain form fields, put two form fields next to one another rather than below and change the label on these two fields to appear above the fields rather then on their left.
I spent hours wading through the different versions of tg docs and the 1.0 API, but I could find nothing that worked. I tried adding:
__field_attrs__={'phone':{'rows':'2'}}
but nothing changed. I am assuming a ListForm does not have field_attrs!? Can anyone point me in the right direction on how to achieve what I am looking for?
Thanks a lot!
You can add CSS classes and styles to your fields like so:
For a completely different layout, you need to subclass
BaseLayout
and reference your own template as explained here: http://tw2core.readthedocs.org/en/latest/design/#template.For instance, I have created a more flexible Layout class called FloatLayout:
It can be used with this FloatForm class:
The Genshi template float_layout.html for the FloatLayout is this:
The Genshi template float_form.html for the FloatForm is this:
A concrete Form could now look like this:
As you see, the fields
remote_account
,new_password
have an attributeaside
which causes them to appear on the same line asuser_name
.