Source of file SectionRevealAnswerBlock.php
Size: 1,527 Bytes - Last Modified: 2021-12-23T10:11:59+00:00
/var/www/docs.ssmods.com/process/src/code/Blocks/RevealAnswerBlock/SectionRevealAnswerBlock.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | <?php class SectionRevealAnswerBlock extends Section { private static $db = array( 'Question' => 'varchar(200)' ); static $has_many = array( 'Answers' => 'Answer' ); public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', TextField::create('Question', 'Question')); $dataColumns = new GridFieldDataColumns(); $dataColumns->setDisplayFields(array('ID' => 'ID', 'ClassName' => 'Class Name', 'Answer' => 'Answer')); //---------------------- Main ----------------------// $saveWarning = LiteralField::create("Warning", "<p class='cms-warning-label'>You must first save before adding answers</p>"); $answers = GridField::create('Answers', 'Answers', $this->Answers(), GridFieldConfig::create()->addComponents( $dataColumns, new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldDetailForm(), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldTitleHeader() ) ); if (!$this->ID) { $answers->getConfig()->removeComponentsByType('GridFieldAddNewButton'); $fields->addFieldToTab('Root.Main', $saveWarning); } $fields->addFieldToTab('Root.Main', $answers); $this->removeEmptyTabs($fields); return $fields; } } |