Wait a sec. callback and target are meant to load a fragment via ajax, but
that doesn't "fire" all the logic needed to intercept FORMs etc.
_callback and _target are meant roughly as an "onclick" under steroids.
(under the hood it translates to an onclick="ajax(url, target)")
What you're trying to achieve is probably offered by the LOAD helper, that
can be exploited in an A() using _href and cid
A('Add to My Charts',_href=URL('subscribe_form',vars={'chartname':
'whatever'}), cid='whatever')
That will load the component and trap all links and form submissions,
because it translates to an onclick="web2py_component(url, target)"
On Wednesday, November 7, 2012 8:39:50 PM UTC+1, Simon Carr wrote:
>
> The URL with the form in is web2py_xlchart_dashboard/charts/user_charts so
> without an action it will submit to *user_charts*, but I need it to
> submit to* subscribe_form *which is the function that was called by AJAX
> to generate the Form.
>
> or am I not understanding something?
>
> Simon
>
> On Wednesday, 7 November 2012 19:26:46 UTC, Derek wrote:
>>
>> Why would you need to create an action for the form? Are you not using
>> self submit?
>>
>> On Wednesday, November 7, 2012 12:22:03 PM UTC-7, Simon Carr wrote:
>>>
>>> I have this piece of code that calls a function in my controller when
>>> clicked.
>>>
>>> {{=A('Add to My Charts',callback=URL('subscribe_form',vars={'chartname':
>>> chart.chartName}),target=str(chart.chartName).replace('.','_'))}}
>>>
>>>
>>> The subscribe_form function looks like this
>>>
>>> def subscribe_form():
>>>
>>> form =
>>> SQLFORM(db.user_chart,fields=['title','description'],hidden=dict(chartname=request.vars['chartname']))
>>> if form.process().accepted:
>>> response.flash = 'form accepted'
>>> elif form.errors:
>>> response.flash = 'form has errors'
>>> else:
>>> response.flash = 'please fill out the form'
>>> return form
>>>
>>> The Form is created by AJAX, but it's action is blank.
>>>
>>> Do I have to specify the action myself if I am build a Form via AJAX?
>>>
>>> Simon
>>>
>>
--