/
EditableFormStep.php
94 lines (81 loc) · 1.86 KB
/
EditableFormStep.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* A step in multi-page user form
*
* @package userforms
*/
class EditableFormStep extends EditableFormField
{
private static $singular_name = 'Page Break';
private static $plural_name = 'Page Breaks';
/**
* Disable selection of step class
*
* @config
* @var bool
*/
private static $hidden = true;
/**
* @return FieldList
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeByName(array('MergeField', 'Default', 'Validation', 'RightTitle'));
return $fields;
}
/**
* @return FormField
*/
public function getFormField()
{
$field = UserFormsStepField::create()
->setName($this->Name)
->setTitle($this->EscapedTitle);
$this->doUpdateFormField($field);
return $field;
}
protected function updateFormField($field)
{
// if this field has an extra class
if ($this->ExtraClass) {
$field->addExtraClass($this->ExtraClass);
}
}
/**
* @return boolean
*/
public function showInReports()
{
return false;
}
public function getInlineClassnameField($column, $fieldClasses)
{
return new LabelField(
$column,
$this->CMSTitle
);
}
public function getCMSTitle()
{
$title = $this->getFieldNumber()
?: $this->Title
?: '';
return _t(
'EditableFormStep.STEP_TITLE',
'Page {page}',
array(
'page' => $title
)
);
}
/**
* Get the JS expression for selecting the holder for this field
*
* @return string
*/
public function getSelectorHolder()
{
return "$(\".step-button-wrapper[data-for='{$this->Name}']\")";
}
}