Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #671 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

[PATCH] widget.TextArea and RemoteForm broken

Reported by: danimal@… Owned by: anonymous
Priority: normal Milestone: 0.9a2
Component: TG Widgets Version:
Severity: normal Keywords:
Cc:

Description

When using widget.TextArea? in a TableForm? I get the value POSTed correctly. When I use a RemoteForm I get no value passed through the POST. Using an error_handler I am told I need to supply a value for the TextArea? as I'm using validator=validators.NotEmpty?. If I don't have the validator then no dict entry shows up in the passed in data.

The following works when used as a form:

class FeatureFields(widgets.WidgetsDeclaration):
    type = widgets.HiddenField(attrs={'value':'Feature'})
    name = widgets.TextField(validator=validators.NotEmpty)
    handle = widgets.TextField(validator=validators.NotEmpty, attrs={'size':30})
    description = widgets.TextArea(validator=validators.NotEmpty)

featureForm = widgets.TableForm(name='FeatureForm', fields=FeatureFields(),
                                 submit_text="Add Feature")

And this does not pass the description at all:

class FeatureFields(widgets.WidgetsDeclaration):
    type = widgets.HiddenField(attrs={'value':'Feature'})
    name = widgets.TextField(validator=validators.NotEmpty)
    handle = widgets.TextField(validator=validators.NotEmpty, attrs={'size':30})
    description = widgets.TextArea(validator=validators.NotEmpty)

featureForm = widgets.RemoteForm(name='FeatureForm', fields=FeatureFields(),
                                 submit_text="Add Feature")

If the TextArea? is switched to a TextField? it works fine, but that's not an option when one needs a TextArea?.

Attachments

tg-ajax.js.patch Download (1007 bytes) - added by danimal@… 11 years ago.
patch to remoteFormRequest javascript to allow widgets.RemoteForm to accept form elements other than INPUT (i.e., TEXTAREA, SELECT, and BUTTON)

Change History

comment:1 Changed 11 years ago by danimal@…

It seems widgets.SingleSelectField? is also broken in RemoteForm. It asks me for "valid" input no matter what selection I choose.

comment:2 Changed 11 years ago by danimal@…

After hitting the SelectField? broken problem I dug into the cause and found that the javascript called when using RemoteForm only checked for form elements of type "input." I'll attach a patch here that fixes the remoteFormRequest() function to look for types 'input,' 'textarea,' 'select,' or 'button.' Now RemoteForm works for me.

Thanks,

Dan Weeks
Software Developer
Wild Brain, Inc.

Changed 11 years ago by danimal@…

patch to remoteFormRequest javascript to allow widgets.RemoteForm to accept form elements other than INPUT (i.e., TEXTAREA, SELECT, and BUTTON)

comment:3 Changed 11 years ago by anonymous

  • Summary changed from widget.TextArea and RemoteForm broken to [PATCH] widget.TextArea and RemoteForm broken

comment:4 Changed 11 years ago by michele

  • Status changed from new to closed
  • Resolution set to fixed

Thanks, committed in r977!

Note: See TracTickets for help on using tickets.