sprox-0.8 with TG2.2 __field_attrs__ rows=

54 views
Skip to first unread message

ozwyzard

unread,
Oct 9, 2012, 1:08:21 AM10/9/12
to sp...@googlegroups.com
I am in the midst of porting an app from TG2.0 (sprox-0.7x) to TG2.2 (sprox-0.8).  The port is going quite well so far.  However, I am seeing exceptions thrown for:

class new_form_type(AddRecordForm):
        ... <various fields>
        __field_attrs__ = {'Name': {'rows': 1},
            'Summary':{'rows': 1}}

widgets.py:308 prepare
Attr param clashes with user-supplied attr: 'rows'

Similar for edit_form_type.

Question: What is the new way to specify the field row size?

Thanks.

Alessandro Molina

unread,
Oct 11, 2012, 4:43:10 AM10/11/12
to sp...@googlegroups.com
You mean rows for a text area?

If you are using TW2 you should be able to do it by doing something like:
__field_attrs__ = {'Name': {'attrs': {'rows': 1}}}

TW2 uses the "attrs" property for tag attributes.
> --
> You received this message because you are subscribed to the Google Groups
> "sprox" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sprox/-/rbWDx2XucrgJ.
> To post to this group, send email to sp...@googlegroups.com.
> To unsubscribe from this group, send email to
> sprox+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sprox?hl=en.

ozwyzard

unread,
Oct 11, 2012, 6:27:07 AM10/11/12
to sp...@googlegroups.com

Thank you.  I tried that but it just stuck an attrs field as follows:

  </tr><tr class="even" id="sx_message:container">
  <th>Message</th>
   <td>
       <textarea attrs="{'cols': 70}" onClick="textCount(140);" name="message" id="sx_message" ></textarea>
        <span id="sx_message:error"></span>
   </td>
</tr>

For example, the onClick attr was placed properly (since there is no collision with tw2 textArea parameters).

      __field_attrs__ = {
            'message': {
                'attrs' : {'cols':70},
                'onClick': 'textCount(%d);' % limits.lim_messagesize_max,

Alessandro Molina

unread,
Oct 11, 2012, 5:59:40 PM10/11/12
to sp...@googlegroups.com
Sorry, I messed up a few things because rows is a Widget attribute in TW2.
In case of widget attributes you cannot set them using
__field_attrs__, you must set the as widget args.

For example:

__field_widget_args__ = {'display_name':{'rows':100}}

Works as expected by setting 100 rows to the form that displays a
Group in a newly quickstarted TurboGears2 project.
> --
> You received this message because you are subscribed to the Google Groups
> "sprox" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sprox/-/B8m-KOqQUIwJ.

ozwyzard

unread,
Oct 11, 2012, 7:39:47 PM10/11/12
to sp...@googlegroups.com
Thank you!  That works!
Reply all
Reply to author
Forward
0 new messages