Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • CheckboxField
  • CheckboxField_Disabled
  • CheckboxField_Readonly
  • CheckboxSetField
  • DropdownField
  • GroupedDropdownField
  • ListboxField
  • LookupField
  • Monument_PolishingTextField
  • NullableField
  • OptionsetField
  • ReadonlyField
  • RoomServiceDropdownField
  • SimpleHTMLEditorField
  • SimpleTinyMCEField
  • SimpleWysiwygField
  • SocleSize_SocleSectionTextField
  • StateDropdownField
  • StateProvinceDropdownField
  • TextareaField
  • TextField
 1 <?php
 2 /**
 3  * Set of radio buttons designed to emulate a dropdown.
 4  * It even uses the same constructor as a dropdown field.
 5  * @package forms
 6  * @subpackage fields-basic
 7  */
 8 class OptionsetField extends DropdownField {
 9     
10     /**
11      * @var Array
12      */
13     protected $disabledItems = array();
14     
15     /**
16      * Creates a new optionset field.
17      * @param name The field name
18      * @param title The field title
19      * @param source An map of the dropdown items
20      * @param value The current value
21      * @param form The parent form
22      */
23     function __construct($name, $title = "", $source = array(), $value = "", $form = null) {
24         parent::__construct($name, $title, $source, $value, $form);
25     }
26 
27     /**
28      * Create a UL tag containing sets of radio buttons and labels.  The IDs are set to
29      * FieldID_ItemKey, where ItemKey is the key with all non-alphanumerics removed.
30      * 
31      * @todo Should use CheckboxField FieldHolder rather than constructing own markup.
32      */
33     function Field() {
34         $options = array();
35         $odd = 0;
36         $source = $this->getSource();
37         foreach($source as $value => $title) {
38             $value_lat = Convert::rus2lat($value);
39             $itemID = $this->id() . "_" . ereg_replace('[^a-zA-Z0-9]+','', $value_lat);
40             
41             $odd = ($odd + 1) % 2;
42             $extraClass = $odd ? "odd" : "even";
43             $extraClass .= " val" . preg_replace('/[^a-zA-Z0-9\-\_]/','_', $value_lat);         
44             $checked = ($value == $this->value) ? 1 : 0;
45             $disabled = ($this->disabled || in_array($value, $this->disabledItems)) ? 1 : 0;
46             
47             $options[] = new ArrayData(array(
48                 'ID' => $itemID,
49                 'Class' => $extraClass,
50                 'Name' => $this->name,
51                 'Value' => $value,
52                 'Title' => $title,
53                 'isChecked' => $value == $this->value,
54                 'isDisabled' => $disabled,
55             ));
56         }
57         $attributes = array(
58             'class' => "optionset {$this->extraClass()}",
59             'id' => $this->id(),
60         );
61         return $this->createTag('input', $attributes, new DataObjectSet($options));
62     }
63 
64     function performReadonlyTransformation() {
65         // Source and values are DataObject sets.
66         $items = $this->getSource();
67         $field = new LookupField($this->name,$this->title ? $this->title : "" ,$items,$this->value);
68         $field->setForm($this->form);
69         $field->setReadonly(true);
70         return $field;
71     }
72     
73     /**
74      * Mark certain elements as disabled,
75      * regardless of the {@link setDisabled()} settings.
76      * 
77      * @param array $items Collection of array keys, as defined in the $source array
78      */
79     function setDisabledItems($items) {
80         $this->disabledItems = $items;
81     }
82     
83     /**
84      * @return Array
85      */
86     function getDisabledItems() {
87         return $this->disabledItems;
88     }
89     
90     function ExtraOptions() {
91         return new DataObjectSet();
92     }
93 }
94 ?>
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0