Re: How to remove sprox submit button

76 views
Skip to first unread message

Mengu

unread,
Jan 4, 2013, 5:07:22 AM1/4/13
to TurboGears
what about a little bit of javascript? $
('input[type="submit"]').hide();

On Jan 3, 10:10 pm, Stuart Zurcher <stuartz.c...@gmail.com> wrote:
> I have tried many different ways to remove the button on a form while using
> sprox on TG2 with tw2:
>
> Class userInfo(diabledForm):
>
>      __model__  = User
>
>      # following methods tried
>
>      button = None
>
>      class __sprox__(object):
>
>           button = None
>
>      __base_widget_args__ ={'button':None}
>
>
>
> I have also varied the name of button to submitButton, submit, Button, etc
> Any ideas?

Scott A. Williams

unread,
Jan 4, 2013, 9:25:12 AM1/4/13
to turbo...@googlegroups.com
Stuart,

Not sure if Sprox changes things, but according to the TW2 source, setting submit to None on a form class should disable the submit button. From tw2.forms.widgets.py:

class Form ( twc . DisplayOnlyWidget ):
    """
    A form, with a submit button. It's common to pass a
    TableLayout or ListLayout widget as the child.
    """
    template = "tw2.forms.templates.form"
    help_msg = twc . Param (
        'This message displays as a div inside the form' ,
        default = None )
    action = twc . Param (
        'URL to submit form data to. If this is None, the form ' +
        'submits to the same URL it was displayed on.' ,
        default = None , attribute = True )
        method = twc . Param ( 'HTTP method used for form submission.' ,
        default = 'post' , attribute = True )
    submit = twc . Param ( 'Submit button widget. If this is None, no submit ' +
        'button is generated.' ,
        default = SubmitButton ( value = 'Save' ))
    buttons = twc . Param ( 'List of additional buttons to be placed at the ' +
        'bottom of the form' ,
        default = [])

Scott


From: "Stuart Zurcher" <stuart...@gmail.com>
To: turbo...@googlegroups.com
Sent: Thursday, January 3, 2013 2:10:32 PM
Subject: [TurboGears] How to remove sprox submit button

Stuart Zurcher

unread,
Jan 4, 2013, 12:13:12 PM1/4/13
to turbo...@googlegroups.com
Thank you, Scott.

One of the first things I tried was:

"submit = None

Stuart

Stuart Zurcher

unread,
Jan 4, 2013, 12:26:59 PM1/4/13
to turbo...@googlegroups.com
Mengu,
Javascript works.  However, I was hoping for something to use in the form setup.  It seems that something is happening behind the scenes in TG 2.2 that prevents some of the examples which apparently works for others in manipulating the button like:

__base_widget_args__ = {'submit_text':'Submit'}

On another form I had to change the "Save" to "Submit" in the tw2.forms.widget.py

Again, I would prefer changing it in the class initiation rather than in the mako template or backend files.

Any suggestions are appreciated.

Alessandro Molina

unread,
Jan 25, 2013, 7:50:41 AM1/25/13
to TurboGears .
class UserController(EasyCrudRestController):
    model = model.User

    __form_options__ = {
        '__base_widget_args__': {'submit':None}
    }

Correctly worked for me in a EasyCrudRestController, doing the same directly on the form should work too.
While to change the submit button text you would do something like:

    __form_options__ = {
        '__base_widget_args__': {'submit':SubmitButton(value='HI')}
    }



--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To view this discussion on the web visit https://groups.google.com/d/msg/turbogears/-/EbgHHn43jYUJ.

To post to this group, send email to turbo...@googlegroups.com.
To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.

Reply all
Reply to author
Forward
0 new messages