There's some problem with what I'm doing now.
I have form = SQLFORM.factory() with all the fields in my controller.
In my db.py file, I am extending auth with
auth.settings.extra_fields['auth_user']= [
Field <http://127.0.0.1:8000/examples/global/vars/Field>('t_image'),
Field <http://127.0.0.1:8000/examples/global/vars/Field>('t_location'),
Field <http://127.0.0.1:8000/examples/global/vars/Field>('t_subjects'),
Field
<http://127.0.0.1:8000/examples/global/vars/Field>('t_qualifications'),
Field <http://127.0.0.1:8000/examples/global/vars/Field>('t_biography'),
Field <http://127.0.0.1:8000/examples/global/vars/Field>('t_hourly_rate'),
Field <http://127.0.0.1:8000/examples/global/vars/Field>('t_modified_on'),
Field <http://127.0.0.1:8000/examples/global/vars/Field>('s_location')]
However, when I visit the page I am getting a bunch of 'None' fields
without input boxes. Am I supposed to somehow
put the SQLFORM.factory info in my db.py file? I can't understand why
it's doing this...
On Wed, Dec 5, 2012 at 12:49 AM, Daniele Pestilli <[email protected]>wrote:
> How can I blank out all the **form.vars in the event that the
> form.vars.is_tutor returns false? Is there a simple way to do this or
> should I manually put in None for all the fields?
>
>
>
> On Tue, Dec 4, 2012 at 8:16 PM, Niphlod <[email protected]> wrote:
>
>> depends on where do you use that kind of logic. If the user is already
>> logged, you need to UPDATE the corresponding "auth_user" row with the data
>> inserted, something among the lines of
>>
>> db(db.auth_user.id == auth.user_id).update(**form.vars)
>>
>> If instead you are requesting the user to fill that form without being
>> logged already, you'd need to CREATE the row, so you should use
>> insert....in that case you should also ask for username/email and the
>> password.
>>
>> summary: form.vars holds a dictionary composed of fieldname --> values.
>> Both .insert() and .update() take a dictionary, in which case the columns
>> corresponding to a table are updated/created with the correct values.
>>
>> On Tuesday, December 4, 2012 8:34:31 PM UTC+1, Daniele wrote:
>>>
>>> And the same goes for db.auth_user.insert() ... does it imply the logged
>>> user or not?
>>>
>>> On Monday, December 3, 2012 2:27:29 PM UTC, Daniele wrote:
>>>>
>>>> Hey guys, I'm wondering if there's a way from the controller to know
>>>> whether a form's boolean field (checkbox) is selected or not. I only want
>>>> to add the info in the form to the database if the checkbox is selected,
>>>> otherwise the controller should not process that form.
>>>>
>>>> Thanks!
>>>>
>>> --
>>
>>
>>
>>
>
>
--