do i need
form=SQLForm(db.student)
somewhere? I tried it with:
{{form=SQLForm(db.student)}}
just above the <form> and it still did not work.
On Mon, Nov 10, 2008 at 4:48 PM, Wes James <[EMAIL PROTECTED]> wrote:
> that should be:
>
> <form enctype="multipart/form-data" class="t2-update" action="" method="post">
>
> <label>{{=db.student.last_name.label}}</label><br>
> <input name="last_name" value="{{=form.latest.last_name}}" />
> {{if form.errors.last_name:}}{{=form.errors.last_name}}{{pass}}
> <br>
> <input type="submit" />
> {{=form.hidden_fields()}}
>
> </form>
>
> On Mon, Nov 10, 2008 at 4:44 PM, Wes James <[EMAIL PROTECTED]> wrote:
>> Model:
>>
>> db=SQLDB('sqlite://db.db')
>>
>> from applications.plugin_t2.modules.t2 import T2
>> t2=T2(request,response,session,cache,T,db,all_in_db=True)
>>
>> db.define_table("student",
>> SQLField("last_name","string",length=30,default=""))
>>
>> db.student.id.default=t2.person_id ## this sets default ownership
>> db.student.email.default=t2.person_email
>>
>> Controller:
>>
>> def login(): return dict(login=t2.login())
>> def logout(): t2.logout(next='login')
>> def register(): return dict(register=t2.register())
>>
>> @t2.requires_login(next='login')
>> def index():
>> if db(db.student.id==t2.person_id).select():
>> form=t2.update(db.student,db.student.id==t2.person_id)
>> else:
>> form=t2.create(db.student)
>> return dict(form=form)
>>
>> @t2.requires_login(next='login')
>> def display():
>> return dict(display=t2.display(db.student))
>>
>> @t2.requires_login(next='login')
>> def update():
>> if not t2.have_access(db.student,t2.id):
>> t2.redirect('index',flash='No access')
>> return dict(update=t2.update(db.student,next='index'))
>>
>> @t2.requires_login(next='login')
>> def download():
>> return t2.download()
>>
>> view:
>>
>> {{extend '../../plugin_t2/views/layout.html'}}
>> {{include}}
>>
>>
>> <form enctype="multipart/form-data" class="t2-update" action=""
>> method="post">
>>
>> <label>{{=db.student.last_name.label}}</label><br>
>> <input name="last_name" value="{{=form.last_name}}" />
>> {{if form.errors.last_name:}}{{=form.errors.last_name}}{{pass}}
>> <br>
>> <input type="submit" />
>> {{=form.hidden_fields()}}
>>
>> </form>
>>
>>
>> On Mon, Nov 10, 2008 at 4:38 PM, mdipierro <[EMAIL PROTECTED]> wrote:
>>>
>>> please show me the model, view and controller, otherwise I am not sure
>>> about the answer.
>>>
>>>
>>> On Nov 10, 5:36 pm, "Wes James" <[EMAIL PROTECTED]> wrote:
>>>> What I am saying is, shouldn't my code below put "joe" in the input
>>>> field by grabbing the current value in the database? It is getting
>>>> None instead of "joe"
>>>>
>>>> On Mon, Nov 10, 2008 at 4:33 PM, mdipierro <[EMAIL PROTECTED]> wrote:
>>>>
>>>> > that if because last name does not have a default.
>>>>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---