Hmm, it works fine for me. Did you do:
{{if 'form' in response._vars:}}
{{=form}}
{{pass}}
For me, if my controller returns dict(..., form=some_form_object), the form
gets displayed, but if the dict does not include a 'form' key, nothing is
displayed, and there is no error.
Anthony
On Wednesday, June 29, 2011 12:50:00 PM UTC-4, David J wrote:
> Strange this did not work.
>
>
> But Bruno's solution did.
>
> if 'form' in globals():
> {{= form }}
>
>
> On 6/29/11 11:40 AM, Anthony wrote:
>
> If you want to test specifically whether 'form' was returned in the dict of
> the controller action (as opposed to possibly being defined in a model
> file), you can also do:
>
> {{if 'form' in response._vars:}}
>
>
> On Wednesday, June 29, 2011 11:02:06 AM UTC-4, rochacbruno wrote:
>
>> {{if 'form' in globals():}}
>> {{=form }}
>> {{pass}}
>>
>>
>>
>> On Wed, Jun 29, 2011 at 12:00 PM, David J. <[email protected]> wrote:
>>
>>> I am wondering why if I dont return anything in my dict and in my view
>>>
>>> {{if form:}}
>>> {{= form }}
>>> {{pass}}
>>>
>>> I get an exception.
>>>
>>>
>>> S'Traceback (most recent call last):\n File
>>> "/apps/www/web2py.trunk/gluon/restricted.py", line 192, in restricted\n
>>> exec ccode in environment\n File
>>> "/apps/www/web2py.trunk/applications/sms/views/default/campaign.html", line
>>> 87, in <module>\nNameError: name \'form\' is not defined\n'
>>>
>>>
>>> I want to be able to check if a key is there before I use it.
>>>
>>> Thanks.
>>>
>>
>>
>