Canvas development: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 33: Line 33:
* '''tabname''' is name of tab or page where initial form was stored. In most cases it is value "card".   
* '''tabname''' is name of tab or page where initial form was stored. In most cases it is value "card".   


For example, we will use value "'''societe@companies'''" for canvas parameter. This is a value of an already coded demo canvas template for third parties, not used in a standard usage of Dolibarr but provided as "demo". So URL to create a third party using this alternative template is now:
For example, we will use value "'''societe@company'''" for canvas parameter. This is a value of an already coded demo canvas template for third parties, not used in a standard usage of Dolibarr but provided as "demo". So URL to create a third party using this alternative template is now:


'''http://mydomain/societe/soc.php?action=create&leftmenu=customers&canvas=societe@companies'''
'''http://mydomain/societe/soc.php?action=create&leftmenu=customers&canvas=societe@company'''


This means the form to create the third party will be found into template file:
This means the form to create the third party will be found into template file:


'''/societe/canvas/companies/tpl/card_create.tpl'''
'''/societe/canvas/company/tpl/card_create.tpl'''


So to use you own template, just choose a value for '''mymodule''', '''mycanvas''', copy and paste a demo template found into Dolibarr directories with new directory and new file name and then edit the template like you want. Template contains all the part under the top menu and at right of left menu. You can change look, field order, add your javascript controls, remove or add your own fields. The only requirement is to keep mandatory fields with same name to avoid errors when you will submit the page. Fields removed will be filled with null or 0 into database. New fields for the moment are ignored. We will see later how we can add code to save them.
So to use you own template, just choose a value for '''mymodule''', '''mycanvas''', copy and paste a demo template found into Dolibarr directories with new directory and new file name and then edit the template like you want. Template contains all the part under the top menu and at right of left menu. You can change look, field order, add your javascript controls, remove or add your own fields. The only requirement is to keep mandatory fields with same name to avoid errors when you will submit the page. Fields removed will be filled with null or 0 into database. New fields for the moment are ignored. We will see later how we can add code to save them.

Navigation menu