Subforms

35 views
Skip to first unread message

Carlos Daniel Ruvalcaba Valenzuela

unread,
Sep 25, 2011, 4:35:14 AM9/25/11
to sp...@googlegroups.com
Hello, I have a couple of questions regarding sprox:

Does Sprox support subforms? for example, a field in my model is a
relationship to another model, maybe a fixed one-to-one, does sprox
support adding a complete form to edit this field? as far as I can see
in the docs there is nothing like it, the only way would be to send a
separate form for it to the template.

My other question is about internationalization, is there any way to
provide translations for sprox forms? maybe through SQLAlchemy Column
parameters (such as doc or info), as far I can see there this question
was asked a bit ago in this list with no real answer.

Regards,
Carlos Ruvalcaba

percious

unread,
Sep 27, 2011, 11:59:39 AM9/27/11
to sp...@googlegroups.com
There has been interest in doing sub-forms with sprox for a while.  I believe Kai Groner wanted to implement it but I am uncertain how far he got with it.  It'd certainly be great to have for mongo support.  Here's Kai's fork: https://bitbucket.org/groner/sprox-0.7 .  Perhaps he will comment.

As for i18n.  I would look into what toscawidgets prescribes for this.  Anything that tw does, we do by virtue of extension.  If you have a specific i18n question, such as: how do I internationalize a field name, that'd probably be more helpful to ask, and is something we can add to the documentation.

cheers.
-chris

Tobias Bieniek

unread,
Nov 24, 2012, 5:51:47 PM11/24/12
to sp...@googlegroups.com
I've just found a way of translating the sprox labels. The key to all this seems to be the __field_widget_args__ attribute of the ViewBase class. Here is a snippet of code that worked okay for me in one of my projects:

class NewUserForm(AddRecordForm):
    __model__ = User
    __required_fields__ = ['password']
    __limit_fields__ = ['email_address', 'display_name', 'password', 'verify_password']
    __base_validator__ = user_validator
    __field_widget_args__ = {
        'email_address': dict(label_text=l_('eMail Address')),
        'display_name': dict(label_text=l_('Name')),
        'password': dict(label_text=l_('Password')),
        'verify_password': dict(label_text=l_('Verify Password')),
    }

    email_address = Field(TextField, Email(not_empty=True))
    display_name = Field(TextField, NotEmpty)
    password = String(min=6)
    verify_password = PasswordField('verify_password')

percious

unread,
Nov 25, 2012, 12:44:29 PM11/25/12
to sp...@googlegroups.com
I think your post found it's way to the wrong thread... Yes, this is the best way to ad i18n to sprox field labels.  I've done this successfully in other projects.

To get back to the original thread's question.  I have recently implemented tgext.subform, thanks to the gracious contribution of nixusoftware.com.  Right now there are no docs, but if you need help using it feel free to write me. Right now it depends on tgext.dojo.  Tested to work in IE7+ too.


cheers.
-chris

percious

unread,
Nov 25, 2012, 12:45:44 PM11/25/12
to sp...@googlegroups.com
sorry, that should read tw.dojo, not tgext.dojo.

-chris

Tobias Bieniek

unread,
Nov 25, 2012, 12:54:18 PM11/25/12
to sp...@googlegroups.com
well, I was a trying to answer to the second question: "is there any way to provide translations for sprox forms?". but if that was related to the subforms too then you might be right. I've never used subforms so far so I can't comment on that...
Reply all
Reply to author
Forward
0 new messages