As mentioned earlier, there are no limitations to what a plugin is, or is capable of. Take for example the SessionData plugin. It takes a parameter, and based on that, it populates a hidden field with that data from the session. Another, more complex example, is the ManyToMany plugin. Notice how in the bundled examples, the ManyToMany plugin does not correlate to a field in the database. Finally, the Image and File plugins upload and delete files accordingly.
For example, say you want to create a new plugin called ColorPicker. The first step would be to create a new file called colorpicker.php in your Plugins directory (codex/application/plugins/). Here is the basic interface of a plugin:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class ColorPicker extends codexForms
{
function ColorPicker($name,$params) {
codexForms::initiate($name,$params);
}
function getHTML(){
}
}
?>
The constructor initiates the parameters that are associated with that plugin, and the getHTML() returns the HTML associated with that plugin (to be printed in the form).
As mentioned earlier, there are various hooks and callbacks that get called on all the plugins automatically, you have the option of overloading these should your plugin require it.
You can access all the form field values in a post insert or post edit hook, through the $_POST array.
Within your plugin, you can access the id of the table that the controller is operating on with the following:
$CI = &get_instance();
$id = $CI->codexadmin->active_id;
This hook gets called before an element is to be inserted to the database.
This hook gets called after a record is inserted to the database.
This hook gets called before a record will be updated.
This hook gets called after a record is updated.
Given the raw $value from the form, this function will "prep" it for the database. This means that it should be filtered to prevent SQL injection attacks.
See prepForDisplay($field,$value).
Returns the name that is displayed in the header row of the Overview page.
If the plugin pulls data from other tables, then this function returns the tablename.fieldname of that plugin.
Returns the name of the table associated with the plugin.