Skip to content

Commit

Permalink
FIX Allow multi readonly trans in TextCheckboxGroupField
Browse files Browse the repository at this point in the history
Fixes #630
  • Loading branch information
chillu committed Mar 18, 2019
1 parent 735d43d commit a255676
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/Forms/TextCheckboxGroupField.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,27 @@ public function __construct($title = null)
*/
public function performReadonlyTransformation()
{
$field = parent::performReadonlyTransformation();
$field = $this;

$field->setTemplate(CompositeField::class);
$field->setTitle('Title');
if (!$this->readonly) {
$field = parent::performReadonlyTransformation();

$field->replaceField('Title', LiteralField::create(
'Title',
$field->fieldByName('Title')->Value()
));
$field->setTemplate(CompositeField::class);
$field->setTitle('Title');

$displayedText = _t(__CLASS__ . '.DISPLAYED', 'Displayed');
$notDisplayedText = _t(__CLASS__ . '.NOT_DISPLAYED', 'Not displayed');
$field->replaceField('Title', LiteralField::create(
'Title',
$field->fieldByName('Title')->Value()
));

$field->replaceField('ShowTitle', LiteralField::create(
'ShowTitle',
$field->fieldByName('ShowTitle')->Value() === 'Yes' ? $displayedText : $notDisplayedText
)->addExtraClass('show-title'));
$displayedText = _t(__CLASS__ . '.DISPLAYED', 'Displayed');
$notDisplayedText = _t(__CLASS__ . '.NOT_DISPLAYED', 'Not displayed');

$field->replaceField('ShowTitle', LiteralField::create(
'ShowTitle',
$field->fieldByName('ShowTitle')->Value() === 'Yes' ? $displayedText : $notDisplayedText
)->addExtraClass('show-title'));
}

return $field;
}
Expand Down

0 comments on commit a255676

Please # to comment.