Question: How do I append skill_and_experience as a list:string into the field added_term as 'English': '1 year', 'Math':'2 years',...etc.
Model.py:
db.define_table( 'Experience',Field('Experience_level'), format = '%(Experience_level)s')
db.define_table( 'teaching',Field('teach_string'), format = '%(teach_string)s')
db.define_table( 'add_list_item',
Field('skill_list', db.teaching, label='Enter Your Skills sets', comment = 'Enter skills'),
Field('Experience_list', db.Experience, label='Enter Your Experience', comment = 'Enter years'))
db.define_table( 'Project',
Field("Title", "string", requires=IS_NOT_EMPTY(),default=None),
Field("added_term", "list:string", requires=IS_NOT_EMPTY()),)
Controller:
def create_table():
a_list = 'My skills and experience:'
skill_and_experience = [];
form1 = SQLFORM(db.Project)
form2 = SQLFORM(db.add_list_item, submit_button=' + Add',).process()
form2.element('input[type=submit]').update(_class='btn btn-custom')
if form2.accepted:
skill_and_experience = skills.teach_string+':' +''+ experience.Experience_level
added_term.append(skill_and_experience)
response.flash = T("Added Experience")
if form1.accepted:
response.flash = T("success!")
return dict(form1 = form1, form2 = form2, a_list = a_list)
View:
{{extend 'layout.html'}}
<center>
{{=form1.custom.begin}}
<div class="input-title">
{{=form1.custom.widget.Title}}
<br>
{{=form2.custom.begin}}
<h4>{{=a_list}}</h4>
<table>
<thead>
<tr>
<div class="skill_list">
<td> {{=form2.custom.widget.skill_list}} </td>
<div class="exp_list">
<td>{{=form2.custom.widget.Experience_list}} </td>
<div class="add_button">
<td> {{=form2.custom.submit}} </td>
</tr>
</thead>
</table>
<br>
<br>
{{=form2.custom.end}}
{{=form1.custom.submit}}
</div>
</div>
</div>
</div>
{{=form1.custom.end}}
</center>
<style>
.input-title{
height: 100px;
width: 400px;
}
#add_list_item_skill_list{
width: 200px;
}
#add_list_item_Experience_list{
width: 200px;
}
.btn-custom { text-align:right;color: blue;width:50px; padding:20%;position: relative;top: -4px;left: 4px;height 20px;}
</style>
The idea is to basically add experience and training using form2 and add that to form1 and then process both. But I am having problem in appending data into list:string like I would for project.