Thanks Anthony for your response, it looks like this will generate UI based
on the record but I have my own custom html on which I have to perform
submit operation , second thing i have to display all inserted records in
different custom html with some extra information also how to achieve it in
web2py?
For example:
I have employe table filled with some employee records and i have to read
the table and display the employees on one html page , in addition to that
i have to provide provision to the user that they can modify the record
from there means there will be one modify button available  for each
employee record so user can click which can open employee edit html page
and from there user can change employee details and save it to the
database, what is the best way to achieve it in web2py?

Regards,
Amit

On Wed, Aug 22, 2012 at 8:38 PM, Anthony <abasta...@gmail.com> wrote:

> Note, you don't necessarily need to do this with two separate actions:
>
> def copy_record():
>     form = FORM('Enter record ID:', INPUT(_name='id', _type='integer'),
>                 INPUT(_type='submit', _value='Submit'))
>     if request.post_vars.id:
>         record = db.table1(request.post_vars.id)
>         if record:
>             db.table2.insert(**db.table2._filter_fields(record))
>             response.flash = 'The record was copied'
>         else:
>             response.flash = 'A record with ID %s does not exist.' %request
> .post_vars.id
>     return dict(form=form)
>
> Then in the copy_record.html view, you just need:
>
> {{=form}}
>
> Anthony
>
> On Wednesday, August 22, 2012 2:12:45 AM UTC-4, Khalil KHAMLICHI wrote:
>
>> 1) controller page1: controllers/default.py
>>
>> def page1:
>> return dict()
>>
>> 2) view page1: views/default/page1.html
>>
>> page1.html content :
>>
>> <form name="text_form" action="page2.html" method="get">
>>  Please Enter ID: <input type="text" name="EneteredID" />
>> <input type="submit" value="Submit" />
>> </form>
>>
>> 3) controller page2: controllers/default.py
>>
>> def page2():
>> EnteredID = request.vars['EnteredID']
>> # 1 - check if record exists
>> record = db(db.YourTableNameHere.ID == EnteredID).select()[0]
>> if len(record):
>> # 2 insert it into a second table
>> db(db.SecondTableName).insert(**field1=record.field1,
>> field2=record.field2, field3=record.field3 )
>> return dict( result='Success' )
>> else:
>> return dict( result='Record Not Found')
>>
>> I believe you can build on top of this.
>>
>>
>> On Wed, Aug 22, 2012 at 6:52 AM, Amit <amit.k...@gmail.com> wrote:
>>
>>> Hi,
>>> I generated one custom html file which is having one text field where
>>> user has to enter id and one submit button.
>>>
>>> I have to use it in following manner:
>>> 1. User has to enter the id and press the submit button
>>> 2. after pressing submit button, id value has to be validated in xyz
>>> table.
>>> 3. first it has to validate whether entered id is available in xyz table
>>> or not, if not available then it has to notify the user about it
>>> 4. if id is available in xyz table then it will fetch the record of id
>>> from xyz table and insert it to another table called abc table.
>>>
>>> problem facing:
>>> I have to add this html to my web2py project and achieve the above
>>> functionality  , Can anybody help me to provide the solution how to use
>>> custom html and database interaction with it?
>>>
>>> --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 



Reply via email to