I know this was a while ago, but I had a similar question and came across
this thread. You can turn off the built in edit button by choosing
editable=False, then create you own using links
def example():
query = db.sometable
links = [lambda row: A('Edit',_class='button btn
btn-default',_href=URL("default","custom_edit_page",args=[row.id]))]
grid = SQLFORM.grid(query, links = links, editable=False)
return dict(grid = grid)
def custom_edit_page():
edit_item = request.args(0) or redirect(URL('example'))
form = crud.update(db.sometable, edit_item, next='example')
On Monday, April 14, 2014 6:17:46 AM UTC-7, Tim Price wrote:
>
> And what about if I do want to create my own edit form from scratch? How
> do I get the 'edit' button on the SQLFORM.grid to link to my custom form?
>
> On Friday, February 21, 2014 2:32:25 PM UTC+1, Anthony wrote:
>>
>> You can also customize the edit form created by the grid in the usual
>> ways (without creating your own form from scratch), including having custom
>> view code or specifying an alternative view altogether.
>>
>> Anthony
>>
>> On Friday, February 21, 2014 7:57:42 AM UTC-5, Luca Guerrieri wrote:
>>>
>>> Looks like it's my tie to post an answer :-))
>>>
>>> To customize the edit form or new form in a SQLFORM.grid i put in the
>>> controller, but exactly
>>> before the sqlform.grid creation and with a return ...
>>>
>>> if request.args(0) in ['edit']:
>>> response.flash=T("Edit form")
>>> response.view = 'default/editclist.html'
>>> form = SQLFORM(db.mylist, db.mylist(request.args(2)))
>>> if form.process().accepted:
>>> response.flash = 'Update form accepted'
>>> elif form.errors:
>>> response.flash = 'Update form rejected, there are errors'
>>> return dict(form=form)
>>>
>>> in this way I can have an edit or whatever i need ... customized ...
>>> my custom view will be under default the editclist.html in which there
>>> will be a {{=form}}
>>>
>>>
>>> p.s.: now I'm fighting with a links=links customization ... but this is
>>> another question :-))
>>>
>>>
>>> Il giorno giovedì 20 febbraio 2014 16:35:17 UTC+1, Luca Guerrieri ha
>>> scritto:
>>>>
>>>> Dear all,
>>>> after some new things i have understood on web2py I'm not able to find
>>>> this solution :
>>>>
>>>> I've a sqlform.grid which becomes from a 2 tables query
>>>>
>>>> ... some customization code ....
>>>>
>>>> form = SQLFORM.grid(query=query, left = db.mylist.on(db.person.id ==
>>>> db.mylist.name ) , field_id = (db.mylist.id), fields=fields,
>>>> headers=headers, orderby=default_sort_order, create=False,
>>>> deletable=False,
>>>> editable=True, showbuttontext=False, maxtextlength=64, paginate=100,
>>>> user_signature=False, searchable = True, details = True)
>>>>
>>>>
>>>>
>>>> db.define_table('person',
>>>> Field('name', 'string'),
>>>> Field('dob', length=10),
>>>> Field('address', 'text', length=255),
>>>> Field('countryname'),
>>>> )
>>>>
>>>> db.define_table('mylist',
>>>> Field('object', 'string', length=6, required=True),
>>>> Field('name', db.person),
>>>> Field('zip', length=5, required=False),
>>>> )
>>>>
>>>> When i click on the edit button related to a row (the pencil at the end
>>>> of every record row) , I would edit that values through a form on which i
>>>> can find
>>>> the values viewed in the row. That is possible for all the values
>>>> become from the first table (cardlist) but not for that become from the
>>>> second table (person)
>>>>
>>>> precisely i can read the ID of the second table but not the value
>>>> referred to
>>>> eg : editing the row I have a form with : object, zip and instead the
>>>> name of the person its id ...
>>>>
>>>> There is a way to customize the edit form connected to the sqlform.grid
>>>> item ?
>>>>
>>>> Thank You
>>>>
>>>>
>>>>
--
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.