Canvas development: Difference between revisions

Jump to navigation Jump to search
Line 44: Line 44:
'''/societe/canvas/companies/tpl/card_create.tpl'''
'''/societe/canvas/companies/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 file name and then edit the template like you want. You can remove or add your own fields but you must always keep mandatory fields in your form to avoid errors when you will submit the page. Fields removed will be filled with null 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.


Once this is done, you must now add the new create URL into Dolibarr menus or replace the existing one with new one. For this take a look at page [[Menus_system]].
Once this is done, you must now add the new create URL into Dolibarr menus or replace the existing one with new one. For this take a look at page [[Menus_system]].


Note that when a record is saved using a canvas, the canvas name "mymodule@mycanvas" is also stored into database. This is important because this means, Dolibarr will be able to know that this record is a canvas and not the other so it will be able to them suggest a view or edit form dedicated for this record only and keep using standard forms for other records. See next chapters.
Note that when a record is saved using a canvas, the canvas name '''mymodule@mycanvas''' is also stored into database. This is important because this means, Dolibarr will be able to know that this record is a canvas and not the other so it will be able to them suggest a view or edit form dedicated for this record only and keep using standard forms for other records. See next chapters.


= Replace an edit form with your own template =
= Replace an edit form with your own template =

Navigation menu