silverstripe-userforms/code/model/editableformfields/EditableFormStep.php
2015-08-14 14:51:56 +12:00

78 lines
1.3 KiB
PHP

<?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', 'DisplayRules'));
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
)
);
}
}