1 <?php
2 3 4 5 6 7
8 class extends DatalessField {
9
10 11 12
13 protected $headingLevel = 2;
14
15 function __construct($name, $title = null, $headingLevel = 2, $allowHTML = false, $form = null) {
16
17
18 $args = func_get_args();
19 if(!isset($args[1]) || is_numeric($args[1])) {
20 $title = (isset($args[0])) ? $args[0] : null;
21
22
23 $name = 'HeaderField' . $title;
24 $headingLevel = (isset($args[1])) ? $args[1] : null;
25 $allowHTML = (isset($args[2])) ? $args[2] : null;
26 $form = (isset($args[3])) ? $args[3] : null;
27 }
28
29 if($headingLevel) $this->headingLevel = $headingLevel;
30 $this->allowHTML = $allowHTML;
31
32 parent::__construct($name, $title, null, $allowHTML, $form);
33 }
34
35 function Field() {
36 $attributes = array(
37 'class' => $this->extraClass(),
38 'id' => $this->id()
39 );
40 return $this->createTag(
41 "h{$this->headingLevel}",
42 $attributes,
43 ($this->getAllowHTML() ? $this->title : Convert::raw2xml($this->title))
44 );
45 }
46 }
47 ?>
[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.
-