labelMore = _t('ToggleField.MORE', 'more'); $this->labelLess = _t('ToggleField.LESS', 'less'); $this->startClosed(true); parent::__construct($name, $title, $value); } function Field() { $content = ''; Requirements::javascript("jsparty/prototype.js"); Requirements::javascript("jsparty/behaviour.js"); Requirements::javascript("jsparty/prototype_improvements.js"); Requirements::javascript("sapphire/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