2015-08-12 06:08:32 +02:00
|
|
|
<?php
|
|
|
|
|
2017-08-09 01:55:09 +02:00
|
|
|
namespace SilverStripe\UserForms\FormField;
|
|
|
|
|
|
|
|
use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroupEnd;
|
2017-08-11 02:36:28 +02:00
|
|
|
use SilverStripe\UserForms\Model\EditableFormField;
|
2017-08-09 01:55:09 +02:00
|
|
|
|
2015-08-12 06:08:32 +02:00
|
|
|
/**
|
|
|
|
* Front end composite field for userforms
|
|
|
|
*/
|
2016-07-21 07:53:59 +02:00
|
|
|
class UserFormsGroupField extends UserFormsCompositeField
|
|
|
|
{
|
|
|
|
public function __construct($children = null)
|
|
|
|
{
|
|
|
|
parent::__construct($children);
|
|
|
|
$this->setTag('fieldset');
|
|
|
|
}
|
2015-08-12 06:08:32 +02:00
|
|
|
|
2016-07-21 07:53:59 +02:00
|
|
|
public function getLegend()
|
|
|
|
{
|
|
|
|
// Legend defaults to title
|
|
|
|
return parent::getLegend() ?: $this->Title();
|
|
|
|
}
|
2015-09-11 00:20:06 +02:00
|
|
|
|
2016-07-21 07:53:59 +02:00
|
|
|
public function processNext(EditableFormField $field)
|
|
|
|
{
|
|
|
|
// When ending a group, jump up one level
|
|
|
|
if ($field instanceof EditableFieldGroupEnd) {
|
|
|
|
return $this->getParent();
|
|
|
|
}
|
2015-08-12 06:08:32 +02:00
|
|
|
|
2016-07-21 07:53:59 +02:00
|
|
|
// Otherwise behave as per normal composite field
|
|
|
|
return parent::processNext($field);
|
|
|
|
}
|
2015-08-12 06:08:32 +02:00
|
|
|
}
|