With empty action field I mean:
<form action="" enctype="multipart/form-data" method="post">

and this is not empty action field
<form action="/testapp/default/index" enctype="multipart/form-data"
method="post">

I used this line in my view:
{{=form.custom.begin.replace('action=""', 'action="%s"' % URL('index'))}}
and output in source is:
&lt;form  action=&quot;/moje0/default/index&quot;
enctype=&quot;multipart/form-data&quot; method=&quot;post&quot;&gt;
and in browser I get this:
<form action="/moje0/default/index" enctype="multipart/form-data"
method="post">
just to put this what I see to code and everything is than resolved.

Thanks

- - Miroslav Gojic - -


On Sun, Oct 16, 2011 at 19:41, Anthony <abasta...@gmail.com> wrote:
> I see the problem -- setting the '_action' attribute after the form is
> created doesn't affect form.custom.begin, which is what you are using.
> Instead, try this in the view:
> {{=form.custom.begin.replace('action=""', 'action="%s"' % URL()}}
> URL() should generate the URL of the current action (though it won't include
> args and vars, so you'll have to add those explicitly if your URL happens to
> use them).
> However, I'm not sure it's necessary to have a non-empty action for valid
> HTML5 -- see #9
> here: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-algorithm.
> An empty action appears to be valid.
> Anthony
> On Sunday, October 16, 2011 12:50:29 PM UTC-4, miroslavgojic wrote:
>>
>> I try next example and all mentioned options:
>>
>> def people():
>>     form = crud.create(db.person,next=URL('people'),message=T("record
>> created"))
>>     form['_action'] = URL('index')
>>     return dict(form = form)
>>
>> but my action field in form is empty.
>
> What do you mean the action field is empty? When I try the exact code above,
> I get the following in the resulting source html:
> <form action="/testapp/default/index" enctype="multipart/form-data"
> method="post">
>
> Are you expecting something else?
>>
>> - - Miroslav Gojic - -
>>
>> On Sun, Oct 16, 2011 at 16:09, Anthony <abas...@gmail.com> wrote:
>> > On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote:
>> >>
>> >> I tray to put mentioned examples into controller after my form
>> >> definition
>> >>
>> >> form['_action'] = URL(index')
>> >> form.update(_action=URL('index'))
>> >> form.attributes.update(_action=URL('index'))
>> >>
>> >> but it is not happened anything,
>> >
>> > What exactly happened? I assume this does change the form action as
>> > expected, but then nothing happens when you submit the form? When you
>> > change
>> > the form action, the form will get submitted to that action. If you
>> > submit
>> > the form to 'index', then your 'index' function will have to process the
>> > submitted form -- if there's no code in your 'index' function to do so,
>> > then
>> > nothing will happen. In web2py, forms are typically self-submitting
>> > (i.e.,
>> > submitted to the action that generated them). Is there a reason you want
>> > to
>> > submit the form to a different action?
>> >
>> >>
>> >> and if I change my value I just get error
>> >>
>> >> form.update(_action=my_value) - this make error
>> >
>> > What is my_value? Is it a URL?
>> >
>> >>
>> >> In view after beginning of form.custom.start I tray next similar code
>> >> {{=form['_action'] = URL(index')}}
>> >
>> > I assume you mean form.custom.begin? Anyway, it will not work to change
>> > the
>> > form action after that because form.custom.begin actually inserts the
>> > <form>
>> > tag with the action specified -- so changing the action after will not
>> > affect the way the form is serialized.
>> > Anthony
>> >
>

Reply via email to