Class TreeMultiselectField
This formfield represents many-many joins using a tree selector shown in a dropdown styled element which can be added to any form usually in the CMS.
This form class allows you to represent Many-Many Joins in a handy single
field. The field has javascript which generates a AJAX tree of the site
structure allowing you to save selected options to a component set on a given
DataObject.
Saving
This field saves a ComponentSet object which is present on the DataObject passed by the form, returned by calling a function with the same
name as the field. The Join is updated by running setByIDList on the ComponentSet
Customizing Save Behaviour
Before the data is saved, you can modify the ID list sent to the ComponentSet by specifying a function on the DataObject called
"onChange[fieldname](&items)". This will be passed by reference the IDlist
(an array of ID's) from the Treefield to be saved to the component set.
Returning false on this method will prevent treemultiselect from saving to
the ComponentSet of the given DataObject
// Called when we try and set the Parents() component set // by Tree Multiselect Field in the administration. function onChangeParents(&$items) { // This ensures this DataObject can never be a parent of itself if($items){ foreach($items as $k => $id){ if($id == $this->ID){ unset($items[$k]); } } } return true; }
- Object
-
ViewableData
implements
IteratorAggregate
-
RequestHandler
-
FormField
-
TreeDropdownField
-
TreeMultiselectField
Direct known subclasses
See: TreeDropdownField for the sample implementation, but only allowing single selects
Located at sapphire/forms/TreeMultiselectField.php
Methods summary
public
|
#
__construct( string $name, string $title = null, sourceObject $sourceObject = "Group", string $keyField = "ID", string $labelField = "Title" )
CAVEAT: for search to work properly $labelField must be a database field, or you need to setSearchFunction. |
public
|
|
public
string
|
|
public
|
#
saveInto(
Save the results into the form Calls function $record->onChange($items) before saving to the assummed Component set. |
public
|
Methods inherited from TreeDropdownField
extraClass(),
filterMarking(),
getShowSearch(),
objectForKey(),
populateIDs(),
setChildrenMethod(),
setFilterFunction(),
setSearchFunction(),
setShowSearch(),
setTreeBaseID(),
tree()
Methods inherited from FormField
FieldHolder(),
ID(),
LeftTitle(),
Link(),
Message(),
MessageType(),
Name(),
Required(),
RightTitle(),
SmallFieldHolder(),
Title(),
Type(),
Value(),
addExtraClass(),
attrTitle(),
attrValue(),
createTag(),
dataValue(),
debug(),
describe(),
forTemplate(),
getAttribute(),
getAttributes(),
getAttributesHTML(),
getCustomValidationMessage(),
getDescription(),
getFieldHolderTemplate(),
getFieldHolderTemplates(),
getForm(),
getName(),
getSmallFieldHolderTemplate(),
getSmallFieldHolderTemplates(),
getTabIndex(),
getTemplate(),
getTemplates(),
hasClass(),
hasData(),
isComposite(),
isDisabled(),
isReadonly(),
name_to_label(),
performDisabledTransformation(),
removeExtraClass(),
rootFieldList(),
rootFieldSet(),
securityTokenEnabled(),
setAttribute(),
setContainerFieldList(),
setContainerFieldSet(),
setCustomValidationMessage(),
setDescription(),
setDisabled(),
setError(),
setFieldHolderTemplate(),
setForm(),
setLeftTitle(),
setName(),
setReadonly(),
setRightTitle(),
setSmallFieldHolderTemplate(),
setTabIndex(),
setTemplate(),
setTitle(),
setValue(),
transform(),
validate()
Methods inherited from RequestHandler
allowedActions(),
checkAccessAction(),
getRequest(),
handleRequest(),
hasAction(),
httpError(),
isAjax(),
setDataModel(),
setRequest()
Methods inherited from ViewableData
ATT_val(),
CSSClasses(),
Debug(),
JS_val(),
Me(),
RAW_val(),
SQL_val(),
ThemeDir(),
XML_val(),
__get(),
__isset(),
__set(),
buildCastingCache(),
cachedCall(),
castingClass(),
castingHelper(),
castingHelperPair(),
castingObjectCreator(),
castingObjectCreatorPair(),
customise(),
defineMethods(),
escapeTypeForField(),
getField(),
getIterator(),
getXMLValues(),
hasField(),
hasValue(),
obj(),
renderWith(),
setCustomisedObj(),
setField()
Methods inherited from Object
__call(),
__toString(),
addMethodsFrom(),
addStaticVars(),
addWrapperMethod(),
add_extension(),
add_static_var(),
allMethodNames(),
cacheToFile(),
clearCache(),
combined_static(),
config(),
create(),
createMethod(),
create_from_string(),
exists(),
extend(),
getCustomClass(),
getExtensionInstance(),
getExtensionInstances(),
get_extensions(),
get_extra_config_sources(),
get_static(),
hasExtension(),
hasMethod(),
has_extension(),
invokeWithExtensions(),
is_a(),
loadCache(),
parentClass(),
parse_class_spec(),
remove_extension(),
sanitiseCachename(),
saveCache(),
set_stat(),
set_static(),
set_uninherited(),
stat(),
static_lookup(),
strong_create(),
uninherited(),
uninherited_static(),
useCustomClass()
Magic methods summary
Properties summary
Properties inherited from TreeDropdownField
$allowed_actions,
$baseID,
$childrenMethod,
$filterCallback,
$keyField,
$labelField,
$searchCallback,
$searchExpanded,
$searchIds,
$showSearch,
$url_handlers
Properties inherited from FormField
$attributes,
$containerFieldList,
$customValidationMessage,
$description,
$disabled,
$dontEscape,
$extraClass,
$extraClasses,
$fieldHolderTemplate,
$form,
$leftTitle,
$message,
$messageType,
$name,
$readonly,
$rightTitle,
$smallFieldHolderTemplate,
$template,
$title,
$value
Properties inherited from RequestHandler
$brokenOnConstruct,
$model,
$request
Properties inherited from ViewableData
$casting,
$customisedObject,
$default_cast,
$failover
Comments
Use the Silverstripe Forum to ask questions.