silverstripe-userforms/code/model/editableformfields/EditableFormStep.php

87 lines
1.5 KiB
PHP
Raw Normal View History

2015-08-04 07:12:17 +02:00
<?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';
2015-08-11 08:21:43 +02:00
/**
* Disable selection of step class
*
* @config
* @var bool
*/
private static $hidden = true;
2015-08-04 07:12:17 +02:00
/**
* @return FieldList
*/
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeByName(array('MergeField', 'Default', 'Validation', 'RightTitle'));
2015-08-04 07:12:17 +02:00
return $fields;
}
/**
* @return FormField
*/
public function getFormField() {
$field = UserFormsStepField::create()
2015-08-14 04:51:42 +02:00
->setName($this->Name)
->setTitle($this->EscapedTitle);
$this->doUpdateFormField($field);
return $field;
}
protected function updateFormField($field) {
// if this field has an extra class
2015-08-14 04:51:42 +02:00
if($this->ExtraClass) {
$field->addExtraClass($this->ExtraClass);
}
2015-08-04 07:12:17 +02:00
}
/**
* @return boolean
*/
public function showInReports() {
return false;
}
public function getInlineClassnameField($column, $fieldClasses) {
return new LabelField(
$column,
$this->CMSTitle
);
}
public function getCMSTitle() {
2015-08-14 04:51:42 +02:00
$title = $this->getFieldNumber()
?: $this->Title
?: '';
return _t(
'EditableFormStep.STEP_TITLE',
'Page {page}',
array(
'page' => $title
)
);
}
2015-08-17 00:43:51 +02:00
/**
* Get the JS expression for selecting the holder for this field
*
* @return string
*/
public function getSelectorHolder() {
return "$(\".step-button-wrapper[data-for='{$this->Name}']\")";
}
2015-08-04 07:12:17 +02:00
}