[web2py] Re: SQLFORM.factory upload field can't show link

2016-03-01 Thread killzane
It's work! Thanks! Anthony於 2016年3月1日星期二 UTC+8上午2時24分48秒寫道: > > The default value should be the file name, but you don't have to set it > when you define the table in the model. Instead, set the default in the > controller right *before* you create the form: > > db.project.project_pdf.default =

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-29 Thread Anthony
The default value should be the file name, but you don't have to set it when you define the table in the model. Instead, set the default in the controller right *before* you create the form: db.project.project_pdf.default = the_file_name Simply setting form.vars.project_pdf will not work. Anth

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-28 Thread killzane
So if I have this field in db.project Field('project_pdf', 'upload', label='Project PDF', comment='', uploadfolder ='app/uploads'), I must change to Field('project_pdf', 'upload', label='Project PDF', comment='', uploadfolder ='app/uploads', default=''), what content should I put in "default" att

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-28 Thread Anthony
The widget gets created when the form is initialized, so if you want to specify a value for the file URL, you should do it by setting the "default" attribute of the upload field in the db.project table *before* creating the table. Anthony On Sunday, February 28, 2016 at 10:07:28 AM UTC-5, kill

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-28 Thread killzane
I want to modify a record from db.project, and there are a reference field in db.project. So I use SQLFORM.factory to add field to put reference list name. the code I paste is simplify version here is full code form = SQLFORM.factory(Field('list_name', 'string', label='List Name'), db. project, d

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-28 Thread Anthony
Sorry, still not clear what you are trying to do, and you have not explained why you are iterating over the Fields of the db.project table. On Sunday, February 28, 2016 at 3:48:26 AM UTC-5, killzane wrote: > > Because I want to add other field to the form so I use SQLFORM.factory. > > And this is

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-28 Thread killzane
Because I want to add other field to the form so I use SQLFORM.factory. And this is my __copydata method def __copydata(src, dest, fields): if src: for k in fields: if src.has_key(k): dest[k] = src[k] return dict() Anthony於 2016年2月26日星期五 UTC+8下午9時08分1

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-26 Thread Anthony
> for t in db.project: > query = (t.id == request.vars.id) > __copydata(db(query).select(limitby=(0,1)).first(), form.vars, > t.fields) > The above is confusing and cannot be the actual code, as it would raise an exception. When you iterate over db.project, you get its Field objects (

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-25 Thread killzane
This is the code in my controller form = SQLFORM.factory(Field('list_name', 'string', label='List Name'), db. project, table_name='project',upload=URL('download')) for t in db.project: query = (t.id == request.vars.id) __copydata(db(query).select(limitby=(0,1)).first(), form.vars, t.field

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-25 Thread Anthony
Can you show the code you are using to edit an existing record via SQLFORM.factory? On Thursday, February 25, 2016 at 10:50:12 AM UTC-5, killzane wrote: > > Yes, I mean when I want to edit an existing record, there are no link. > But I can find the file when use appadmin. > > Anthony於 2016年2月25日

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-25 Thread killzane
Yes, I mean when I want to edit an existing record, there are no link. But I can find the file when use appadmin. Anthony於 2016年2月25日星期四 UTC+8下午10時41分32秒寫道: > > There should only be a file link if you are editing an existing record > (with an existing file). If you are displaying a "create" form

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-25 Thread Anthony
There should only be a file link if you are editing an existing record (with an existing file). If you are displaying a "create" form, to what file would you expect such a link to point? Anthony On Thursday, February 25, 2016 at 4:19:10 AM UTC-5, killzane wrote: > > This is my code > form = SQL