Basically... right now I have a magnifying glass, the pencil, and a trash
can for my records. I want to add a plus next to each one of my records and
when I click on the plus it copies that records values into a new record
and creates a new ID.
I can then modify some of the values in the record or keep it the same if I
choose. Does that make sense?
On Friday, May 2, 2014 9:57:23 AM UTC-4, LoveWeb2py wrote:
>
> This is very helpful, Richard. I have about 20 fields so I think I would
> have to iterate through the fields and insert the request.vars to the
> database.
>
> Ahhh after looking at your code it looks like that could would write a
> record from one table to another. In this case I just want to copy a record
> from the same table and insert the record as a new ID.
>
> I think the answer will be a combination of your and Oli's approach.
>
>
> On Friday, May 2, 2014 9:39:46 AM UTC-4, Richard wrote:
>>
>> What do you mean?
>>
>> You can redirect (A('Link', _href=URL(controler, function,
>> vars=dict(pass_your_record_vars_here=record_vars1, ...))) to a function
>> that do what I wrote above... Just pass record value throught vars then
>> request.vars.field1 request.vars.field2 and assign .default=
>> request.vars.field1
>>
>> Richard
>>
>>
>>
>> On Fri, May 2, 2014 at 9:33 AM, LoveWeb2py <[email protected]> wrote:
>>
>>> Richard,
>>>
>>> How do I assign this to a button though?
>>>
>>>
>>> On Friday, May 2, 2014 9:30:21 AM UTC-4, Richard wrote:
>>>
>>>> keepvalues
>>>>
>>>> or
>>>>
>>>> row = db(...).select(db.table.record).first()
>>>>
>>>> db.other_table.field1.default = row.field
>>>>
>>>> form = SQLFORM(db.table, ...)
>>>>
>>>> Richard
>>>>
>>>>
>>>> On Fri, May 2, 2014 at 9:07 AM, Oli <[email protected]> wrote:
>>>>
>>>>> I hope this help.
>>>>>
>>>>> def copy_and_edit():
>>>>> """
>>>>> copy_and_edit
>>>>> """
>>>>> record = db.t_disciplin(request.args[0])
>>>>>
>>>>> vals = {}
>>>>> for k,v in record.items():
>>>>> if k in db.t_disciplin.fields:
>>>>> if k == 'f_title':
>>>>> v = v + "_copy"
>>>>> recname = str(v) # Needed to redirect the page to the
>>>>> right record
>>>>> if k != 'id':
>>>>> vals[k] = v
>>>>>
>>>>> db.t_disziplin.insert(**vals)
>>>>>
>>>>> rec = db(db.t_disziplin.f_title == recname).select().first()
>>>>> rec_id = rec.id
>>>>>
>>>>> # redirect for edit the new record
>>>>> redirect(URL(r=request, f='konstanten/t_disciplin/
>>>>> edit/t_disciplin',args=str(rec_id)))
>>>>>
>>>>>
>>>>>
>>>>> Am Freitag, 2. Mai 2014 14:29:26 UTC+2 schrieb LoveWeb2py:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> There are many times when I just want to copy the values of one
>>>>>> record in my sqlform and create a new record, but modify the content and
>>>>>> save it. Is there an easy way to do this with web2py or would I have to
>>>>>> write the code?
>>>>>>
>>>>>> Many thanks
>>>>>>
>>>>> --
>>>>> Resources:
>>>>> - http://web2py.com
>>>>> - http://web2py.com/book (Documentation)
>>>>> - http://github.com/web2py/web2py (Source code)
>>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "web2py-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.