Now that I think about it, this is overkill. It's just a simple form tag (no 
custom web2py classes or attributes), so probably just as easy to hand code 
the HTML (which will also be more clear).

On Sunday, October 16, 2011 6:05:41 PM UTC-4, miroslavgojic wrote:
>
> After some time and several trays I get solution
>
> in view for custom form I used 
> {{=XML(form.custom.begin.replace('action=""', 'action="people"'))}}
>
> and it produce code in source:
> <form  action="people" enctype="multipart/form-data" method="post">
>
> and my form now work and I have not empty action field
>
> Thanks everybody for help
>
>
> - - Miroslav Gojic - -
>
>
> On Sun, Oct 16, 2011 at 19:41, Anthony <abas...@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 <aba...@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