By default, every element of an ImpressCMS Persistable Object will have a form element determined by its data type. You can change this behavior by using the setControl method of the object.

File: libraries/icms/ipf/Object.php

There are 2 arguments for setControl - the element (field) name, and the options array.

The simplest use of this method is to identify the element and a core form element. For example, let's say you have an object called 'project' and an element called 'active', defined as an integer. By default, the integer data type would use a text box. But, you want a simple radio button group of yes or no. First, you initialize the element, then you can use setControl to change the field to display as a yes/no option with the following:

$this->quickInitVar('status', XOBJ_DTYPE_INT);
$this->setControl('status', 'yesno');

 When you use setControl, the ImpressCMS core will first try to find a IPF form element that has already been defined, looking for icms_ipf_form_elements_{Yourcontrolname}. If this is found, your field will be rendered with that element instead of the default for the data type.

If the control specified is not found in the core, it will check to see if the module calling for that control has provided a custom control to use. ImpressCMS looks in the modules/{yourmodule}/class/form/elements/ folder to find a file with the name {yourmodule}{yourcontrol}element.php. That file should contain the class declaration and logic for your element. The class name would follow the same pattern as the file name - {Yourmodule}{Yourcontrol}Element - and the class name would capitalize the first letter of the module name, the control name, and the suffix 'Element'.

Last modified on 2014/8/28 by Anonymous
The comments are owned by the poster. We aren't responsible for their content.