-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSegmentTitle.php
52 lines (38 loc) · 1.12 KB
/
SegmentTitle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
declare(strict_types=1);
namespace Laravolt\SemanticForm\Elements;
class SegmentTitle extends Wrapper
{
protected static $template = "<h3 class='ui blue ribbon label'>%s</h3>";
public static function setTemplate(string $template)
{
static::$template = $template;
}
public function render()
{
$element = clone $this;
if ($this->label) {
$element->label = false;
$field = $this->decorateField(new Field($this->label, $element));
if ($control = $element->getPrimaryControl()) {
$field->addClass($control->fieldWidth);
}
return $field->render();
}
$element->beforeRender();
$html = '';
foreach ($element->controls as $control) {
$html .= sprintf(static::$template, $control);
}
$html .= $element->renderHint();
return $html;
}
public function display()
{
$output = '';
foreach ($this->controls as $control) {
$output .= sprintf(static::$template, $control);
}
return $output;
}
}