1 <?php
2
3 4 5 6 7 8
9
10 class EditableOption extends DataObject {
11
12 static $default_sort = "Sort";
13
14 static $db = array(
15 "Name" => "Varchar(255)",
16 "Title" => "Varchar(255)",
17 "Default" => "Boolean",
18 "Sort" => "Int"
19 );
20
21 static $has_one = array(
22 "Parent" => "EditableMultipleOptionField",
23 );
24
25 static $extensions = array(
26 "Versioned('Stage', 'Live')"
27 );
28
29 30 31
32 public function EditSegment() {
33 return $this->renderWith('EditableOption');
34 }
35
36 37 38 39 40
41 public function TitleField() {
42 return new TextField("Fields[{$this->ParentID}][{$this->ID}][Title]", null, $this->Title );
43 }
44
45 46 47 48 49
50 public function FieldName() {
51 return "Fields[{$this->ParentID}][{$this->ID}]";
52 }
53
54 55 56 57 58
59 public function populateFromPostData($data) {
60 $this->Title = (isset($data['Title'])) ? $data['Title'] : "";
61 $this->Default = (isset($data['Default'])) ? $data['Default'] : "";
62 $this->Sort = (isset($data['Sort'])) ? $data['Sort'] : 0;
63 $this->write();
64 }
65
66 67 68
69 public function ReadonlyOption() {
70 $this->readonly = true;
71 return $this->EditSegment();
72 }
73 }
[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.
-