On Sep 7, 2006, at 4:58 PM, Evin wrote:

>
> Hey All,
>
> Relatively new to the Turbogears framework but I love it so far...
>
> I am trying to get more control over the form layout in the TableForm
> template.  I can get it to work but I am having trouble getting all  
> the
> elements to the .KID template. This is what I have right now:
> userform.kid
>
> <div id = "userForm">
>     <form xmlns:py="http://purl.org/kid/ns#";
>         name="${name}"
>         action="${action}"
>         method="${method}"
>         class="tableform"
>         py:attrs="form_attrs"
>>
>         <table py:attrs="table_attrs">
>             <tr>
>                 <th><label class="fieldlabel"
> for="field_id_for('first_name')">First Name:</label></th>
>                 <td><span py:content="display_field_for('first_name')"
> /></td>
>                 <th><label class="fieldlabel"
> for="field_id_for('last_name')">Last Name:</label></th>
>                 <td><span py:content="display_field_for('last_name')"
> /></td>
>                 <th><label class="fieldlabel"
> for="field_id_for('display_name')">Display Name:</label></th>
>                 <td><span
> py:content="display_field_for('display_name')" /></td>
>             </tr>
>             <tr><p /></tr>
>             <tr>
>                 <th><label class="fieldlabel"
> for="field_id_for('user_name')">User Name:</label></th>
>                 <td><span py:content="display_field_for('user_name')"
> /></td>
>                 <th><label class="fieldlabel"
> for="field_id_for('user_password')">Password:</label></th>
>                 <td><span
> py:content="display_field_for('user_password')" /></td>
>                 <th><label class="fieldlabel"
> for="field_id_for('conf_password')">Confirm Password:</label></th>
>                 <td><span
> py:content="display_field_for('conf_password')" /></td>
>             </tr>
>             <tr>
>                 <td colspan="4"
> py:content="submit.display(submit_text)" />
>             </tr>
>         </table>
>     </form>
> </div>
>
> This works fine but I don't know how to get at the "help_text" fields
> or the "label" fields in the template.
>
> I read a discussion on the TRAC site ( i think ticket 636 ) where it
> talks about a field_for('<widget_name>') call but that doesn't seem to
> work.
>
> Am I missing something...

S**t!!  this is scaaary...You just read my mind! (no joke) :D
Since revision 1855 (SVN) which I comitted about an hour ago I just  
implemented this . If you dare to:

$ svn co http://www.turbogears.org/svn/turbogears/branches/1.0  
turbogears
$ cd turbogears
$ sudo python setup.py develop

(on unix)

you can now do:

field_for('user_password').help_text
field_for('user_password').label
field_for('user_password').fq_name
this one is to get the fully-qualified name that the widget will  
render (this makes sense when you have nested fieldsets or repeating  
fieldsets)
field_for('user_password').error (equivalent to error_for 
('user_password'))
or even (if you really enjoy typing):
field_for('user_password').display(
        value_for('user_password'), **params_for('user_password')
        )

from within your forms and fieldsets templates to get complete  
control over the layout. Even for the help_text and label.

Alberto

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to