我们如何在Boolean
中显示getCMSFields()
变量作为只读字段,显示布尔的->Nice()
函数的值(是/否)?< / p>
以下是我的尝试:
class EventMember extends Member {
static $db = array (
'NewsLetter' => 'Boolean'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
//WHAT I TRIED
//$fields->fieldByName('NewsLetter')->performReadonlyTransformation();
/*$newsletter = new ReadonlyField('NewsLetter', 'NewsLetter');
$value = $newsletter->getValue();
$newsletter->setValue($value)->Nice();
$fields->replaceField('NewsLetter', $newsletter);*/
//$fields->addFieldToTab('Root.Main', $nL = CheckboxField::create('NewsLetter', 'Newsletter'));
//$value = $this->NewsLetter->Value()->Nice();
//$nL->setValue($value)->Nice();
$this->extend('updateCMSFields', $fields);
return $fields;
}
}
答案 0 :(得分:1)
$fields->removeByName('NewsLetter');
$nL = DBField::create_field('ReadonlyField', $this->obj('NewsLetter')->Nice(), 'Newsletter');
$fields->addFieldToTab('Root.Main', $nL);