Here is a way of editing records with non id fields:
In the view construct a URL with the record's field value:
{{ =A("edit", URL("", "", "",
)) }}
Then, on the controller, you have to get the record by the field
value:
r = db(db[request.args(0)]. ==
request.args(1)).select().first()
As the field specified is unique, the query should return the proper
record
Lastly, create the form to modify the table record as usual:
form = SQLFORM(db[request.args(0)], r)
I am not sure if this is the best way but should work
On 29 dic, 03:55, JF wrote:
> I think this information was actually somewhere in previous Books, but I
> just can't find it anymore in the 4th version.
>
> I would like to be able to get to a record, let's say from a function
> called "edit". But using a Field from the table, not the id of the table.
>
> Example:
> This is accessed through the id of a record in a
> table.http://127.0.0.1:8000/partcreation/item/edit/1
>
> But I would like to access it through a Field from the same table.
> Obviously this name/number must be
> unique.http://127.0.0.1:8000/partcreation/item/edit/2122-123456789-00
>
> Note that the URL above is not working. I would like to know what would be
> the URL (and the code to put in the function) to use "2122-123456789-00"
> instead of "1".
>
> Thanks,
> JF