Okay I feel stupid :)
Don't add the submit button to the WidgetList, instead do:
progress_note_form=widgets.TableForm(fields=ProgressNoteFields(),
name='pnote_form',
validator=validators.Schema(chained_validators=
[StartEndTime()]),
submit=widgets.SubmitButton(label="", default="Save Note",
attrs={'onclick':
'this.disabled=true'})
)
On Jun 7, 1:06 pm, Kevin <[EMAIL PROTECTED]> wrote:
> I'm trying to handle the submit button in a table form, however the
> TableForm also adds it's own default button. The docs seem to indicate
> this should not happen.
>
> "If, for some reason, you do want to manage the submit button
> yourself, add a widgets.SubmitButton instance to your form. The form
> widgets are smart enough to skip the default when that
> happens."http://docs.turbogears.org/1.0/SimpleWidgetForm?highlight=%28submitbu...
>
> The above does not appear to be accurate.
>
> What I would wish to do is simply add "onclick="this.disabled=true" to
> the submit button to avoid double entries.
> Am I missing something? Or do I have the wrong approach?
>
> class ProgressNoteFields(widgets.WidgetsList):
> client_id = widgets.HiddenField(validator=validators.Int)
> client_name = widgets.Label(label="Client: ")
> goal_statement = widgets.Label(label="Goal: ")
> objectives = widgets.CheckBoxList(options=[],
> validator=validators.Int(),
> label="Objectives: ")
> group = widgets.SingleSelectField(options=get_group_options,
> validator=validators.Int(),
> label="Group: ")
> activity_type =
> widgets.SingleSelectField(options=get_activity_types,
> label="Activity Type: ")
> start_time = widgets.CalendarDateTimePicker(button_text="+",
> label="Start Time: ")
> end_time = widgets.CalendarDateTimePicker(button_text="+",
> label="End Time: ",
> help_text=
> "Date/Time must be in format: YYYY/MM/
> DD hh:mm")
> service_location =
> widgets.TextField(validator=validators.UnicodeString(
> not_empty=True, strip=True, max=32), label="Location: ",
> attrs={'maxlength': 32})
> progress_note =
> widgets.TextArea(validator=validators.UnicodeString(
> not_empty=True,
> strip=True, max=4001),
> label="Note: ",
> attrs={'rows': 20, 'maxlength': 4001,
> 'wrap': 'soft', 'onkeyup':
> "CheckFieldLength(pnote_form_progress_note,
> 'charcount', 'remaining', 4000);",
> 'onkeydown':
> "CheckFieldLength(pnote_form_progress_note,
> 'charcount', 'remaining', 4000);",
> 'onmouseout':
> "CheckFieldLength(pnote_form_progress_note,
> 'charcount', 'remaining', 4000);"
> })
> submit_button = widgets.SubmitButton(label="", default="Save
> Note",
> attrs={'onclick':
> 'this.disabled=true'})
> creator = widgets.Label(label="Creator: ")
> created = widgets.Label(label="Created: ")
> updated = widgets.Label(label="Updated: ")
>
> progress_note_form=widgets.TableForm(fields=ProgressNoteFields(),
>
> name='pnote_form',submit_text='Save Note',
>
> validator=validators.Schema(chained_validators=
>
> [StartEndTime()])
> )
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---