public function Field($properties = array())
 {
     $titleArray = $itemIDs = array();
     $titleList = $itemIDsList = "";
     if ($items = $this->getItems()) {
         foreach ($items as $item) {
             $titleArray[] = $item->Title;
         }
         foreach ($items as $item) {
             $itemIDs[] = $item->ID;
         }
         if ($titleArray) {
             $titleList = implode(", ", $titleArray);
         }
         if ($itemIDs) {
             $itemIDsList = implode(",", $itemIDs);
         }
     }
     $field = new ReadonlyField($this->name . '_ReadonlyValue', $this->title);
     $field->setValue($titleList);
     $field->setForm($this->form);
     $valueField = new HiddenField($this->name);
     $valueField->setValue($itemIDsList);
     $valueField->setForm($this->form);
     return $field->Field() . $valueField->Field();
 }
コード例 #2
0
    public function Field($properties = array())
    {
        $content = '';
        Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
        Requirements::javascript(FRAMEWORK_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_field('Text', $rawInput)->{$this->truncateMethod}();
        }
        // only create togglefield if the truncated content is shorter
        if (strlen($reducedVal) < strlen($rawInput)) {
            $content = <<<HTML
\t\t\t<div class="readonly typography contentLess" style="display: none">
\t\t\t\t{$reducedVal}
\t\t\t\t&nbsp;<a href="#" class="triggerMore">{$this->labelMore}</a>
\t\t\t</div>
\t\t\t<div class="readonly typography contentMore">
\t\t\t\t{$this->value}
\t\t\t\t&nbsp;<a href="#" class="triggerLess">{$this->labelLess}</a>
\t\t\t</div>\t
\t\t\t<br />
\t\t\t<input type="hidden" name="{$this->name}" value="{$valforInput}" />
HTML;
        } else {
            $this->dontEscape = true;
            $content = parent::Field();
        }
        return $content;
    }
コード例 #3
0
 function Field()
 {
     $titleArray = array();
     $titleList = array();
     if ($items = $this->getItems()) {
         foreach ($items as $item) {
             $titleArray[] = $item->Title;
         }
         if ($titleArray) {
             $titleList = implode(", ", $titleArray);
         }
     }
     $field = new ReadonlyField($this->name, $this->title);
     $field->setValue($titleList);
     $field->setForm($this->form);
     return $field->Field();
 }