Split form

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Split form

jrick
Hi,

I'm creating a web interface using seaside that's a bit complicated. One particular annoying part is that I have to use multiple forms:
(1) Form 1 contains some fields
(2) Form 2 is used for uploading images asynchronously
(3) Form 3 contains more fields that really belong to Form 1.
Because of layout and because forms can't be within other forms, I have to have both Form 1 and 3, though really they should be the same form that uses one submit button. Is there a good way to combine the forms in such a way that the callbacks for both forms are evaluated?

I did notice that the _k are identical for both forms.

Cheers,

Jeff

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Split form

Iwan Vosloo
Hi Jeff,


On 04/12/2015 19:05, J.F. Rick wrote:
I'm creating a web interface using seaside that's a bit complicated. One particular annoying part is that I have to use multiple forms:
(1) Form 1 contains some fields
(2) Form 2 is used for uploading images asynchronously
(3) Form 3 contains more fields that really belong to Form 1.
Because of layout and because forms can't be within other forms, I have to have both Form 1 and 3, though really they should be the same form that uses one submit button. Is there a good way to combine the forms in such a way that the callbacks for both forms are evaluated?


In another non-seaside world I have nested forms using the new html5 form= attribute on inputs: https://developer.mozilla.org/en/docs/Web/HTML/Element/Input#attr-form

So you could have HTML like:

<form name="form2"></form>

<form name="merged1and3a">
  <input .../>

  <div>
      <input form="form2".../>
  </div>

  <input .../>
</form>

I have not tried to do this in seaside, but can't think offhand why it would not work...

-Iwan

-- 
Reahl, the Python only web framework: http://www.reahl.org

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Split form

Mariano Martinez Peck
In reply to this post by jrick
Hi Jeff,

I hope I am correct with what I say, but I am not 100% sure. I think you can use Ajax for this. Since you serialize the form you won't need a HTML form tag at all. That is, no need of HTML form (unless it does not harm if you want it as for displaying/css things), and instead of using submit buttons, you use normal buttons with ajax calls and serialization. Example:

html button bePush; onClick: (html jQuery ajax serialize: (html jQuery: '.formToSubmit' ) script: [ :s | self doSomething.
] ); value: 'Click me'.

The basis here is:

1) use bePush because you are using Ajax and so buttons do NOT have to be submit. 
2) The magic here is #serialize: which will serialize and invoke callbacks for those inputs. And the good thing is that it accepts a jQuery as the argument of what to serialize. So you can say, for example, all those elements with css class '.formToSubmit'.  And then, when you render forms 1 and 3, you add css class 'formToSubmit'. If the component is very very large, you can reduce the jquery search for performance (like checking those elements form AND css class formToSubmit etc...).
3) Note that since this is ajax, you could have a couple of headaches. For example, doing an #answer: from within the #script: of the ajax call is not easy. Also, if you are used to normal request, you would re-render everything automatically. Here, unless you do something inside #script: it won't refresh anything. So depending on what you need to you may need to refresh something from there.

If you are used to Ajax this will be very very easy. If you need more help, let me know.


On Fri, Dec 4, 2015 at 2:05 PM, J.F. Rick <[hidden email]> wrote:
Hi,

I'm creating a web interface using seaside that's a bit complicated. One particular annoying part is that I have to use multiple forms:
(1) Form 1 contains some fields
(2) Form 2 is used for uploading images asynchronously
(3) Form 3 contains more fields that really belong to Form 1.
Because of layout and because forms can't be within other forms, I have to have both Form 1 and 3, though really they should be the same form that uses one submit button. Is there a good way to combine the forms in such a way that the callbacks for both forms are evaluated?

I did notice that the _k are identical for both forms.

Cheers,

Jeff

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




--

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Split form

jrick
Thanks. That's a really nice way to do that. I ended up doing it with some Javascript (combining forms before submitting) but this would be less hacky.

Cheers,

Jeff

On Sat, Dec 5, 2015 at 7:11 PM Mariano Martinez Peck <[hidden email]> wrote:
Hi Jeff,

I hope I am correct with what I say, but I am not 100% sure. I think you can use Ajax for this. Since you serialize the form you won't need a HTML form tag at all. That is, no need of HTML form (unless it does not harm if you want it as for displaying/css things), and instead of using submit buttons, you use normal buttons with ajax calls and serialization. Example:

html button bePush; onClick: (html jQuery ajax serialize: (html jQuery: '.formToSubmit' ) script: [ :s | self doSomething.
] ); value: 'Click me'.

The basis here is:

1) use bePush because you are using Ajax and so buttons do NOT have to be submit. 
2) The magic here is #serialize: which will serialize and invoke callbacks for those inputs. And the good thing is that it accepts a jQuery as the argument of what to serialize. So you can say, for example, all those elements with css class '.formToSubmit'.  And then, when you render forms 1 and 3, you add css class 'formToSubmit'. If the component is very very large, you can reduce the jquery search for performance (like checking those elements form AND css class formToSubmit etc...).
3) Note that since this is ajax, you could have a couple of headaches. For example, doing an #answer: from within the #script: of the ajax call is not easy. Also, if you are used to normal request, you would re-render everything automatically. Here, unless you do something inside #script: it won't refresh anything. So depending on what you need to you may need to refresh something from there.

If you are used to Ajax this will be very very easy. If you need more help, let me know.


On Fri, Dec 4, 2015 at 2:05 PM, J.F. Rick <[hidden email]> wrote:
Hi,

I'm creating a web interface using seaside that's a bit complicated. One particular annoying part is that I have to use multiple forms:
(1) Form 1 contains some fields
(2) Form 2 is used for uploading images asynchronously
(3) Form 3 contains more fields that really belong to Form 1.
Because of layout and because forms can't be within other forms, I have to have both Form 1 and 3, though really they should be the same form that uses one submit button. Is there a good way to combine the forms in such a way that the callbacks for both forms are evaluated?

I did notice that the _k are identical for both forms.

Cheers,

Jeff

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside