On Mon, Oct 17, 2011 at 03:11, Anthony <abasta...@gmail.com> wrote:

> 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).


@From Massimo:
you can simply use:
 <form ...>
 instead of
 {{=XML(form.custom.begin.replace(....))}}

my solution is:
{{=XML(form.custom.begin.replace('action=""', 'action="people"'))}}
{{=DIV(DIV('Name:',_id='two'),DIV(form.custom.widget.name
,_id='three'),DIV(form.custom.submit,_id='for'),_id='one')}}
{{=form.custom.end}}

maybe this is not the best practice - but after all at the end everything is
HTML source
I get next HTML source with three line in view:
<form action="people" enctype="multipart/form-data" method="post">
<div id="one">
<div id="two">Name:</div>
<div id="three">
<input class="string" id="person_name" name="name" type="text" value=""/>
</div>
<div id="for">
<input type="submit" value="Submit"/>
</div>
</div>
<div class="hidden">
<input name="_next" type="hidden" value="/moje0/default/people"/>
<input name="_formkey" type="hidden"
value="e0b5af7b-0cad-483b-979d-4f8b014e1d3a"/>
<input name="_formname" type="hidden" value="person/None"/>
</div>
</form>

If I use HTML form or mentioned my example  result is same.
*But how in HTML form get hidden fields, and **
value="e0b5af7b-0cad-483b-979d-4f8b014e1d3a"**  - and this value it is
changed after every form submit?*

I don't know how web2py work, but I can see that is hard coding reduced on
minimum and I get my need very fast.
And after all now it is only 10 (but not more than 14) days how I use
web2py, or how I heard for web2py.
I tray to learn what is happens in web2py when I put some code in controler,
or view, or model, but it take some time to read and tray some example.
And best effect in learning is when you do some examples, and now I do small
examples what I can need later,
My apologies for my questions what sometimes are not ease to understand but
after all I'm beginner at web2py.

Thanks

- - Miroslav Gojic - -

>
>
> 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<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