If you have "if 'new' in request.args:' you should not also need "if
form.create_form" (even if you did, you could simply put them in the same
"if" statement with an "and"). Alternatively, use "if hasattr(form,
'create_form'):" -- all by itself.
Anthony
On Thursday, November 10, 2011 2:48:49 PM UTC-5, Richard wrote:
>
> Here a working piece of code :
>
> def test_sqlformgrid():
> form = SQLFORM.grid(db.TABLE, ui='jquery-ui',
> editable=auth.has_membership('reviewer'),
> deletable=auth.has_membership('reviewer'), formstyle = 'divs')
> if 'new' in request.args:
> if form.create_form
> for i in range(0,len(form.create_form[0])):
> if len(form.create_form[0][i][2][0]) > 0:
> form.create_form[0][i][0].append(SPAN((helpicon(),
> SPAN(form.create_form[0][i][2][0])),_class='tooltip'))
> del(form.create_form[0][i][2])
> return dict(form=form)
>
> Off course the for i in range... Is specific to my need but it the way to
> manipulate the generated html form before it goes in user hand...
>
> :)
>
> Richard
>
> On Thu, Nov 10, 2011 at 2:44 PM, Richard Vézina <[email protected]>wrote:
>
>> It was working "if form.create_form:"...
>>
>> I thought that grid use form variable doesn't matter if the SQLFORM.grid
>> wasn't in a form variable at all...
>>
>> And my bad because I show form = crud... But it was not my
>> SQLFORM.grid... Arrg.
>>
>> Sorry about that...
>>
>> Richard
>>
>> On Thu, Nov 10, 2011 at 1:26 PM, Anthony <[email protected]> wrote:
>>
>>> On Thursday, November 10, 2011 12:42:49 PM UTC-5, Richard wrote:
>>>>
>>>>
>>>> "if 'new' in request.args:" works (allow to load the grid) but the "if
>>>> form.create_form:" not work alone or in conjunction with the former
>>>>
>>>
>>> Yeah, looks like it would have to be something like "if hasattr(form,
>>> 'create_form'):".
>>>
>>
>>
>