This type allows you to control an arbitrary number of "child objects" on a given object.
It can only operate if the storage implementation provides it with a Midgard Object.
The storage location provided by the schema is unused at this time, as child object
operations cannot be undone.
The type can manage an arbitrary number of objects. Each object is identified
by a GUID. It provides management functions for existing child objects which allow you to
add, delete and update them in all variants. These functions are executed immediately on the
storage object, no undo is possible.
Available configuration options:
- child_class: the MidCOM DBA class of the child object
- child_schemadb: Path to DM2 schema database used for child elements
- child_foreign_key_fieldname: the field of the child objects used to connect them to the parent. By default up.
- parent_key_fieldname: field of the parent used as identifier in child objects. Typically id or guid.
- Array child_constraints: Other query constraints for the child objects as arrays containing field, constraint type and value suitable for QB add_constraint usage.
- style_element_name: Name used for the header, footer and item elements of the object list
- window_mode: Whether the composites should be edited in a modal pop-up window instead of in-place. Useful for tight spaces.
- maximum_items: How many items are allowed into the composite. After this creation is disabled.
- enable_creation: Whether creation of new items is allowed
- area_element: The HTML element surrounding the composites. By default div.
- context: Composite context for filtering from several composite items in one schema
- context_key: Composite context key in the child object
Usage
child_constraints
Each child constraint is an array, where the values are fieldname, operator and constraint.
'child_constraints' => array
(
array
(
'creator', // Fieldname
'=', // Operator
midcom_connection::get_user(), // Constraint
),
array
(
'name', // Fieldname
'LIKE', // Operator
'%index%', // Constraint
),
),
Methods
_load_creation_controllers ()
_on_initialize ()
Initialize the class, if necessary, create a callback instance, otherwise
validate that an option array is present.
add_object_item ($identifier)
Adds an item for an existing object
convert_from_csv ($source)
convert_from_storage ($source)
This function loads child objects of the storage object.
It
will leave the field empty in case the storage object is null.
Parameters
$source
convert_to_html ()
Displays the child objects
create_object ($controller)
DM2 creation callback for creating children.
delete_all_objects ()
This call will unconditionally delete all objects currently contained by the type.
Returns
boolean
Indicating success.
delete_object (string $identifier)
Deletes an existing child object.
Parameters
$identifier
string
The identifier of the object that should be deleted.
Returns
boolean
Indicating success.
Properties
String $area_element
Wrapping item tag name
mixed $child_class
MgdSchema class of the child item
Array $child_constraints
Constraints for selecting the correct child items
String $child_foreign_key_fieldname
Key of the child item for linking child to master item
mixed $child_schemadb
midcom_helper_datamanager2_schema compatible schema path of the composite item
String $context
Context for the composite item.
A must if there are more than one composite in one schema.
String $context_key
Key for storing the context information in the child item.
Has to be a property of the child.
Array $defaults
Default values for the composite item
boolean $enable_creation
Should the creation mode be enabled
integer $maximum_items
Maximum amount of items
Array $objects
All objects covered by this field.
The array contains Midgard objects indexed by
their identifier within the field.
Array $orders
Array of orders for sorting the items
String $parent_key_fieldname
Key of the master item for linking child to master item
mixed $style_element_name
array $_controllers
Array of Datamanager 2 controllers for child object display and management
array $_creation_controllers
Array of Datamanager 2 controllers for child object creation
Array $_schemadb
The schema database in use for the child elements