labelMore = _t('ToggleField.MORE', 'more'); $this->labelLess = _t('ToggleField.LESS', 'less'); $this->startClosed(true); parent::__construct($name, $title, $value); } function Field() { $content = ''; Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js"); Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleField.js"); if($this->startClosed) $this->addExtraClass('startClosed'); $valforInput = $this->value ? Convert::raw2att($this->value) : ""; $rawInput = Convert::html2raw($valforInput); if($this->charNum) $reducedVal = substr($rawInput,0,$this->charNum); else $reducedVal = DBField::create('Text',$rawInput)->{$this->truncateMethod}(); // only create togglefield if the truncated content is shorter if(strlen($reducedVal) < strlen($rawInput)) { $content = << $reducedVal $this->labelMore