Reviewed chapter 7 Forms and validators. The chapter deals with multiple forms per page, however a more complex example would be useful.
Let me explain the limitation of the current presentation. The example presented page 178 has a validation button for each form, but it is not possible to validate all forms simulateously through a single button. I would suggest creating a chapter 7.8 Case study Cse study would create a mini application taking advantages of all the material developed in chapter 7. The application would be the fondation for accounting which is a transaction which group together a number of accounting entries. an examples would be: Dr purchase 20 Cr Cash 20 date 01/01.2009 comment: purchase of cream A transaction (called transac in our model) has at least 2 accounting entries (called transaction_line in our model), but can have more than 2. For example adding value sale tax at 20% would give the following entries Dr Cash 1,200 Cr sale 1,000 Cr creditor sale tax collected 1,200 date:01/01/2009 comment: sale of ice creams including sale tax at 20% The simplified model is: db.define_table('transac', SQLField('description', length=100), SQLField('date','date',default=now) ) db.define_table('transaction_line', SQLField('transac', db.transac), SQLField('account',length=25), SQLField('amount_transaction', 'integer'), ) db.transaction_line.transac.requires=IS_IN_DB (db,'transac.id','transac.description') db.transaction_line.amount_transaction.requires=IS_NOT_EMPTY() Please note the usual accounting convention that if amount_transaction is positive then it is a debit, and Then creation of the form becomes more tricky as some elements are related to the table transac and some other elements are linked to multiple entries in the table transaction_line. A visual example of form could be Date: [ ] Description:[ ] account amount [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] The controller would be 1) if a line is empty (meaning all cells of the line are empty), then the line is ignored completely 2) if for a given line any cell has a value, then both account and amount should have a value else there is an error message 3) amount for any line should be different from 0 4) the sum of all amount (amount_transaction) for a given transaction should be equal to zero. Does the suggestion above sound a good idea to any of you? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---