This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation.

Difference between revisions of "Custom Fields"

From Group-Office Groupware and CRM Documentation
Jump to: navigation, search
Line 1: Line 1:
 
Group-Office provides the possibility to add user-defined Custom Fields. These are data entries like the built-in data entries, much like the contacts in the Addressbook module, that admins can add to the existing data entries. For example, as admin, you can create the possibility for users to select an employer associated with a contact. Group-Office has predefined Custom Field types that you can use for your modules. You can add these to your modules with the Custom Fields module.
 
Group-Office provides the possibility to add user-defined Custom Fields. These are data entries like the built-in data entries, much like the contacts in the Addressbook module, that admins can add to the existing data entries. For example, as admin, you can create the possibility for users to select an employer associated with a contact. Group-Office has predefined Custom Field types that you can use for your modules. You can add these to your modules with the Custom Fields module.
  
You can also create new Custom Field types. For this, you need to work with three files:
+
You can also create new Custom Field types. For this, you need to work with at least four files:
 +
#One PHP-file containing a subclass of default_customfield_type, which specifies how your Custom Field should be displayed.
 +
#One JS file of which the purpose is to allow selection of the Custom Field's actual data entry.
 +
#Connected to the previous file, is one CustomField.js that specifies the information needed for Custom Field type selection in the Custom Field module.
 +
#The file containing your modules's main class for registering your Custom Field in an event listener.
 +
 
 +
Here, we will show you how to make your own Custom Field type with an example of adding a contact Custom Field to a contact record.
 +
 
 +
== Subclass of default_customfield_type ==
 +
 
 +
The default_customfield_type class contains public functions for displaying your Custom Field data in, for example, HTML tags. It also contains a public function that allows transformation of the data before storing it in the database. The class is defined in customfields.class.inc.php, though you only need to write your own extension of the class. In our example, we wrote the following subclass:

Revision as of 18:34, 26 February 2010

Group-Office provides the possibility to add user-defined Custom Fields. These are data entries like the built-in data entries, much like the contacts in the Addressbook module, that admins can add to the existing data entries. For example, as admin, you can create the possibility for users to select an employer associated with a contact. Group-Office has predefined Custom Field types that you can use for your modules. You can add these to your modules with the Custom Fields module.

You can also create new Custom Field types. For this, you need to work with at least four files:

  1. One PHP-file containing a subclass of default_customfield_type, which specifies how your Custom Field should be displayed.
  2. One JS file of which the purpose is to allow selection of the Custom Field's actual data entry.
  3. Connected to the previous file, is one CustomField.js that specifies the information needed for Custom Field type selection in the Custom Field module.
  4. The file containing your modules's main class for registering your Custom Field in an event listener.

Here, we will show you how to make your own Custom Field type with an example of adding a contact Custom Field to a contact record.

Subclass of default_customfield_type

The default_customfield_type class contains public functions for displaying your Custom Field data in, for example, HTML tags. It also contains a public function that allows transformation of the data before storing it in the database. The class is defined in customfields.class.inc.php, though you only need to write your own extension of the class. In our example, we wrote the following subclass: