This is best done in JS clientside. something like:
jQuery(function(){
jQuery('#table_field__row').hide();
jQuery('#table_otherfield').change(function(){if(jQuery('#table_otherfield').checked())
jQuery('#table_field__row').show();});
});
On Monday, 11 June 2012 01:08:44 UTC-5, rahulserver wrote:
>
> Is there a way to create a form from controller(or view) in web2py to have
> variable number of fields depending on query?
> To be more specific,I have following table in my model:
>
> db.define_table('Commitments',Field('Account',requires=IS_IN_DB(db,
> db.Account_Master.id, '%(Account)s
> %(State)s')),Field('TID',db.Transaction_Master),Field('Entry_Date','date',default=request.now),Field('pending','boolean',default=True),Field('Due_Date','date'),Field('Mode',requires=IS_IN_SET(('DD','Direct_Banking','Cash','Other')),default='Other'),Field('Amount','integer',default=0),Field('Remark'))
>
> The client wants to select a particular account and find all its entries
> in a form wherein he may check or uncheck the value of field 'pending' and
> accordingly the value of this field gets updated. So this needs a form with
> variable number of rows. I do not want to use sqlform.grid for this and I
> would prefer to have the code in the controller.
>