Usage * * * new OptionsetField( * $name = "Foobar", * $title = "FooBar's optionset", * $source = array( * "1" => "Option 1", * "2" => "Option 2", * "3" => "Option 3", * "4" => "Option 4", * "5" => "Option 5" * ), * $value = "1" * ); * * * You can use the helper functions on data object set to create the source array. eg: * * * //Database request for the object * $myDoSet = DataObject::get("FooBars",""); * if($myDoSet){ * // This returns an array of ID => Title * $map = $myDoSet->toDropDownMap(); * * // Instantiate the OptionsetField * $FieldList = new FieldList( * new OptionsetField( * $name = "Foobar", * $title = "FooBar's optionset", * $source = $map, * $value = $map[0] * ) * ); * } * * // Pass the fields to the form constructor. etc * * * @see CheckboxSetField for multiple selections through checkboxes instead. * @see DropdownField for a simple name\" type=\"radio\" value=\"$key\"$checked $disabled class=\"radio\" /> \n"; } $id = $this->id(); return "\n"; } protected $disabled = false; function setDisabled($val) { $this->disabled = $val; } function performReadonlyTransformation() { // Source and values are DataObject sets. $items = $this->getSource(); $field = new LookupField($this->name,$this->title ? $this->title : "" ,$items,$this->value); $field->setForm($this->form); $field->setReadonly(true); return $field; } /** * Mark certain elements as disabled, * regardless of the {@link setDisabled()} settings. * * @param array $items Collection of array keys, as defined in the $source array */ function setDisabledItems($items) { $this->disabledItems = $items; } /** * @return Array */ function getDisabledItems() { return $this->disabledItems; } function ExtraOptions() { return new ArrayList(); } } ?>