durusmail: quixote-users: some form2 issues
some form2 issues
2004-11-03
2004-11-03
StaticFile cast as str in function return
2004-11-05
2004-11-05
2004-11-05
some form2 issues
Oscar Rambla
2004-11-03
On Tuesday 02 November 2004 16:16, Charles Brandt wrote:

> I've also ran into the issue of ButtonWidget not being in form2/__init__.py
> It seems like it should be included to me too.   I import this manually
> during the declaration of my custom defaultForm(Form) subclass that I use
> to customize form nuances globally (like custom css and widget rendering).
> I also customized the 'add' function as follows:
>
>     def add(self, widget_class, name, *args, **kwargs):
>         """
>         Custom add function to deal with buttons
>         """
>
>         if self._names.has_key(name):
>             raise ValueError, "form already has '%s' widget" % name
>         widget = widget_class(name, *args, **kwargs)
>         self._names[name] = widget
>         if isinstance(widget, SubmitWidget):
>             self.submit_widgets.append(widget) # will be rendered at end
>         elif isinstance(widget, ButtonWidget):
>             self.submit_widgets.append(widget) # will be rendered at end
>         elif isinstance(widget, HiddenWidget):
>             self.hidden_widgets.append(widget) # will be render at
> beginning else:
>             self.widgets.append(widget)
>         return widget
>
> (I needed to get the widget back at some point, hence the return)  Not sure
> if that is something that should be included by default.
>
>
> > - ButtonWidget is not in __init__.py file in form2 directory, so I
> > have to import it like this:
> > from quixote.form2.widget import ButtonWidget. Besides that, what is
> > the proper way to use ButtonWidget? Now it renders as a button with
> > separated description (just like input field)... but I want it to be a
> > javascript button.
> >
> > Thanks!
> > --
> > Ksenia
> > _______________________________________________

Hi,

Playing as devil's advocate :-)

Any event can submit a form with proper javascript event capturing code.
Also, submit_widgets are rendered apart from the rest of widgets in the form
render methods. That can be redefined but then again the layout vs. behaviour
dilema can arise.

In any case, I would prefer a more general solution that at this moment I'm
disabled to propose.

Currently, I use to delegate the resolution of these situations to the request
handler, and free form from taking decissions. BTW I think that is one of the
outstanding differences between form2 and form1, although someone can see it
as inconvenient.


-Oscar Rambla

reply