31,003
edits
| Line 20: | Line 20: | ||
For example, imagine you want to replace the creation form of third parties with your own form. The url is something like | For example, imagine you want to replace the creation form of third parties with your own form. The url is something like | ||
'''http://mydomain/societe/soc.php?action=create&leftmenu=customers | |||
''' | '''http://mydomain/societe/soc.php?action=create&leftmenu=customers''' | ||
After adding the canvas parameter, URL will look like | After adding the canvas parameter, URL will look like | ||
'''http://mydomain/societe/soc.php?action=create&leftmenu=customers&canvas=mymodule@mycanvas | |||
''' | '''http://mydomain/societe/soc.php?action=create&leftmenu=customers&canvas=mymodule@mycanvas''' | ||
When you add a parameter canvas=mymodule@mycanvas on a create page, Dolibarr will use the template file into htdocs called | When you add a parameter canvas=mymodule@mycanvas on a create page, Dolibarr will use the template file into htdocs called | ||
'''/''mymodule''/canvas/''mycanvas''/tpl/''tabname''_create.tpl''' | '''/''mymodule''/canvas/''mycanvas''/tpl/''tabname''_create.tpl''' | ||
where | where | ||
* '''mymodule''' directory is value mymodule found into canvas parameter (you choose this value and create directory with same value. use lower case values). | * '''mymodule''' directory is value mymodule found into canvas parameter (you choose this value and create directory with same value. use lower case values). | ||
| Line 41: | Line 45: | ||
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 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. | ||
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. | |||
= Replace an edit form with your own template = | = Replace an edit form with your own template = | ||