Hi:
I am trying to write a fairly simple custom update form as shown below.
The application is used in a lab to track "jobs" which consist of many
samples each.
The sample names are often more than one word. I am writing a page to edit
the existing data base entry. However, when I set the input
value={{=row.sample_name}} I only get the first word to prepopulate the
input field (i.e. if the sample name is "RED CAR WITH ROOF" , I get--
SAMPLE NAME: RED). I have validated that the sample name are correctly
stored in the database. The problem is with all fields in the SAMPLE
table, not just sample name. Any help would be appreciated.
MODEL:
db.define_table('job',
Field('job_number', 'integer'),
Field('Name),
auth.signature)
db.define_table('sample',
Field('job', 'reference job'),
Field('sample_name', 'text'),
auth.signature)
CONTROLLER:
def edit_job():
grid = SQLFORM.smartgrid(db.job, linked_tables=['sample'])
return locals()
VIEW:
{{extend 'layout.html'}}
{{if 'sample.job' in request.args:}} * # this is true when I click on
the appropriate link in the GRID. This part works as intended. *
{{=form.custom.begin}}
{{job_id=request.args(2)}}* # This gets the db.jobs.id that links to all
the appropriate samples. *
{{rows=db(db.sample.job==job_id).select()}} # Selects the appropriate
rows associated with the job
{{for row in rows:}} #Lists all samples for a job, so I can edit any
and all of them.
<label for="sample_name">
Sample Name:
<input type="text" name="sample_name"
id="sample_sample_name" class="text" value={{=row.sample_name}}/> # This
is the problem, the input field is prepopulated only with the first word of
the sample name.
</label>
{{pass}}
{{=form.custom.submit}}
{{=form.custom.end}}
{{else:}}
{{=grid}} *# This is where the view goes first, after the job is
selected it goes to the above view*
{{pass}}
--
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.