1 <?php
2 3 4 5 6
7 class Tab extends CompositeField {
8 protected $tabSet;
9
10 11 12 13 14 15 16 17
18 public function __construct($name) {
19 $args = func_get_args();
20
21 $name = array_shift($args);
22 if(!is_string($name)) user_error('TabSet::__construct(): $name parameter to a valid string', E_USER_ERROR);
23 $this->name = $name;
24
25 $this->id = preg_replace('/[^0-9A-Za-z]+/', '', $name);
26
27
28
29 if(isset($args[0]) && is_string($args[0])) {
30 $title = array_shift($args);
31 }
32 $this->title = (isset($title)) ? $title : FormField::name_to_label($name);
33
34 parent::__construct($args);
35 }
36
37 public function id() {
38 return $this->tabSet->id() . '_' . $this->id;
39 }
40
41 public function Fields() {
42 return $this->children;
43 }
44
45 public function setTabSet($val) {
46 $this->tabSet = $val;
47 }
48
49 50 51
52 public function fieldByName($name) {
53 foreach($this->children as $child) {
54 if($name == $child->Name()) return $child;
55 }
56 }
57 }
58
59 ?>
[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.
-