Changes

Jump to navigation Jump to search
m
Line 248: Line 248:  
You may want to provide a module that add more fields into forms (input and view) of some elements.  
 
You may want to provide a module that add more fields into forms (input and view) of some elements.  
   −
A heavy solution (but not so bad) may be to replace all pages used to create element (this means disable the "New element" menu entry and adding yours, and disable tab that show element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerfull since you can change everything you want into page).  
+
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the "New element" menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into page).  
    
We will describe here another solution, that works only to "add fields" at end of existing fields, using the element "category" as an example but you can convert this tutorial for invoice, proposal ...
 
We will describe here another solution, that works only to "add fields" at end of existing fields, using the element "category" as an example but you can convert this tutorial for invoice, proposal ...
* First thing is to add a table, owned by your module, to store value of new fields. This table will have only one column called "rowid" (will contains same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].
+
* First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called "rowid" (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].
 
* Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.
 
* Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.
 
If you follow this tutorial, to be able to add fields into category forms, you must do:
 
If you follow this tutorial, to be able to add fields into category forms, you must do:
15

edits

Navigation menu