[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-20 Thread Anthony
Sorry, using your exact code, I cannot reproduce the problem. I am able to edit records (including the article_link field) using the grid. Anthony On Friday, April 20, 2018 at 9:03:50 AM UTC-4, dirman wrote: > > db.define_table('articles', > Field('article_date', 'date'), > Field('article_title'

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-20 Thread dirman
db.define_table('articles', Field('article_date', 'date'), Field('article_title'), Field('article_link', compute=lambda r: r.article_title.replace(' ', '-')), Field('image', 'upload'), Field('body', 'text')) def index(): return dict() def articles() article = db(db.

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-19 Thread Anthony
On Thursday, April 19, 2018 at 3:43:02 PM UTC-4, dirman wrote: > > The page reloads the same SQLFORM edit form page with edited field not > submited > Works for me. Please show all your code and describe the exact workflow. Anthony > -- Resources: - http://web2py.com - http://web2py.com/book

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-19 Thread dirman
The page reloads the same SQLFORM edit form page with edited field not submited On Thursday, April 19, 2018 at 12:33:46 AM UTC, Anthony wrote: > > On Wednesday, April 18, 2018 at 6:21:12 PM UTC-4, dirman wrote: >> >> Working after adding compute=lambda >> >> Field('link', compute=lambda r: r.art

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-18 Thread Anthony
On Wednesday, April 18, 2018 at 6:21:12 PM UTC-4, dirman wrote: > > Working after adding compute=lambda > > Field('link', compute=lambda r: r.article_link.replace(' ', '-')) > Sorry, forgot the "compute=". I've updated my original response. > However the table fields can not be updated using gr

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-18 Thread dirman
Working after adding compute=lambda Field('link', compute=lambda r: r.article_link.replace(' ', '-')) However the table fields can not be updated using grid On Wednesday, April 18, 2018 at 6:12:40 PM UTC, Anthony wrote: > > On Wednesday, April 18, 2018 at 10:57:11 AM UTC-4, dirman wrote: >> >>

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-18 Thread Anthony
On Wednesday, April 18, 2018 at 10:57:11 AM UTC-4, dirman wrote: > > http://.../articles/high-temperature-in-city > > def articles(): > news = db(db.articles.article_link==request.args[0]).select()[0] > return(news=news) > I see. Yes, if you need to use the values to make a database

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-18 Thread dirman
http://.../articles/high-temperature-in-city def articles(): news = db(db.articles.article_link==request.args[0]).select()[0] return(news=news) On Wednesday, April 18, 2018 at 2:28:41 PM UTC, Anthony wrote: > > On Wednesday, April 18, 2018 at 10:24:21 AM UTC-4, dirman wrote: >> >> I

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-18 Thread Anthony
On Wednesday, April 18, 2018 at 10:24:21 AM UTC-4, dirman wrote: > > I tried virtual field but can not use it as request args to select the > records > Not sure what you mean by that. What does request args have to do with it? Can you show your code? > They do not appear in the list table fie

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-18 Thread dirman
Any example?. what i want to do is to use article_link as request args to select the records instead of record.id On Wednesday, April 18, 2018 at 11:16:35 AM UTC, 黄祥 wrote: > > perhaps you can use before_insert callback or onvalidate, then assign > article_link with the article_title that alrea

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-18 Thread dirman
I tried virtual field but can not use it as request args to select the records They do not appear in the list table fields. I got a ticket using the computed field example Field('article_link', lambda r: r.article_title.replace(' ', '-')) or also Field('article_link', lambda r: r['article_tit

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-18 Thread Anthony
You probably want a computed field . Field('article_link', lambda r: r.article_title.replace(' ', '-')) Alternatively, to avoid storing redundant data in the database, you can instead use a virtual fi

[web2py] Re: Automatically repeat field text in another before record insertion

2018-04-18 Thread 黄祥
perhaps you can use before_insert callback or onvalidate, then assign article_link with the article_title that already converted with function .replace('', '-') best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (So