Hi everyone,
I am using a bunch of jQuery hide effects based on the example code in the
book... (Chapter 11... Conditional fields in forms) which work great with
my SQLFORM.
However when I change the controller to use SQLFORM.factory so that I can
post to two tables (based on Chapter 7... One form for multiple tables) the
effects stop working. Can someone suggest a workaround or a code change so
that they will work together?
The Controller...
@auth.requires_login()
def appointments():
call_id = request.get_vars.id
db.appointments.business.default=call_id
db.notes.business.default=call_id
form = SQLFORM.factory(db.appointments, db.notes)
if form.process().accepted:
id =
db.appointments.insert(**db.appointments._filter_fields(form.vars))
form.vars.appointments=id
id = db.notes.insert(**db.notes._filter_fields(form.vars))
session.flash = 'Success'
redirect(URL('calls'))
elif form.errors:
response.flash = 'Form has errors'
else:
response.flash = 'Enter Data'
return dict(form=form)
and the View...
{{extend 'layout.html'}}
{{=form}}
<script>
jQuery(document).ready(function(){
if(jQuery('#appointments_unit').prop('checked'))
jQuery('#appointments_unit_type__row').show(),
jQuery('#appointments_unit_number__row').show();
else jQuery('#appointments_unit_type__row').hide(),
jQuery('#appointments_unit_number__row').hide();
jQuery('#appointments_unit').change(function(){
if(jQuery('#appointments_unit').prop('checked'))
jQuery('#appointments_unit_type__row').show(),
jQuery('#appointments_unit_number__row').show();
else jQuery('#appointments_unit_type__row').hide(),
jQuery('#appointments_unit_number__row').hide();
});
if(jQuery('#appointments_level_floor').prop('checked'))
jQuery('#appointments_level_type__row').show(),
jQuery('#appointments_level_number__row').show();
else jQuery('#appointments_level_type__row').hide(),
jQuery('#appointments_level_number__row').hide();
jQuery('#appointments_level_floor').change(function(){
if(jQuery('#appointments_level_floor').prop('checked'))
jQuery('#appointments_level_type__row').show(),
jQuery('#appointments_level_number__row').show();
else jQuery('#appointments_level_type__row').hide(),
jQuery('#appointments_level_number__row').hide();
});
if(jQuery('#appointments_building').prop('checked'))
jQuery('#appointments_building_number__row').show(),
jQuery('#appointments_building_name__row').show();
else jQuery('#appointments_building_number__row').hide(),
jQuery('#appointments_building_name__row').hide();
jQuery('#appointments_building').change(function(){
if(jQuery('#appointments_building').prop('checked'))
jQuery('#appointments_building_number__row').show(),
jQuery('#appointments_building_name__row').show();
else jQuery('#appointments_building_number__row').hide(),
jQuery('#appointments_building_name__row').hide();
});
if(jQuery('#appointments_lot').prop('checked'))
jQuery('#appointments_lot_section__row').show();
else jQuery('#appointments_lot_section__row').hide();
jQuery('#appointments_lot').change(function(){
if(jQuery('#appointments_lot').prop('checked'))
jQuery('#appointments_lot_section__row').show();
else jQuery('#appointments_lot_section__row').hide();
});
if(jQuery('#appointments_cross_street').prop('checked'))
jQuery('#appointments_street_number__row').hide(),
jQuery('#appointments_cross_name__row').show(),
jQuery('#appointments_cross_type__row').show(),
jQuery('#appointments_cross_suffix__row').show();
else jQuery('#appointments_street_number__row').show(),
jQuery('#appointments_cross_name__row').hide(),
jQuery('#appointments_cross_type__row').hide(),
jQuery('#appointments_cross_suffix__row').hide();
jQuery('#appointments_cross_street').change(function(){
if(jQuery('#appointments_cross_street').prop('checked'))
jQuery('#appointments_street_number__row').hide(),
jQuery('#appointments_cross_name__row').show(),
jQuery('#appointments_cross_type__row').show(),
jQuery('#appointments_cross_suffix__row').show();
else jQuery('#appointments_street_number__row').show(),
jQuery('#appointments_cross_name__row').hide(),
jQuery('#appointments_cross_type__row').hide(),
jQuery('#appointments_cross_suffix__row').hide();
});
$('#appointments_appt_date').pickadate({
formatSubmit: 'yyyy-mm-dd',
hiddenName: true
})
$('#appointments_appt_time').pickatime({
formatSubmit: 'HH:i',
hiddenName: true
})
});
</script>
--
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.