0

我正在使用 Zoo CCK,并且已经修改了足够长的代码以使其看起来像我想要的那样。但是,当我提交项目时,我收到一个我无法弄清楚的错误(在标题中)。

为了减少混淆,我应该提到我对文件所做的编辑是添加 $message 的部分以及识别它的任何相关代码。

任何帮助,将不胜感激。下面是文件代码:

错误:保存项目时出错(名称无效)

<?php

// no direct access
defined('_JEXEC') or die('Restricted access');

// register ElementOption class
App::getInstance('zoo')->loader->register('ElementOption', 'elements:option/option.php');
// register ElementRepeatable class
App::getInstance('zoo')->loader->register('ElementRepeatable', 'elements:repeatable/repeatable.php');
/*
Class: ElementSelect
    The select element class
*/

class ElementMessage extends ElementOption implements iSubmittable  {

/*
   Function: edit
       Renders the edit form field.

   Returns:
       String - html
*/
public function edit(){

    $this->app->document->addStylesheet('elements:message/assets/css/submission.css');
    // init vars
    $options_from_config = $this->config->get('option', array());
    $multiple            = $this->config->get('multiple');
    $default             = $this->config->get('default');
    $name                = $this->config->get('name');
    $message         = $this->get('message');

    if (count($options_from_config)) {

        // set default, if item is new
        if ($default != '' && $this->_item != null && $this->_item->id == 0) {
            $this->set('option', $default);
        }

        $options = array();
        if (!$multiple) {
            $options[] = $this->app->html->_('select.option', '', '-' . JText::sprintf('Select %s', $name) . '-');
        }
        foreach ($options_from_config as $option) {
            $options[] = $this->app->html->_('select.option', $option['value'], $option['name']);
        }

        $style = $multiple ? 'multiple="multiple" size="5"' : '';

        $html[] = $this->app->html->_('select.genericlist', $options, $this->getControlName('option', true), $style, 'value', 'text', $this->get('option', array()));
        $html[] = $this->app->html->_('control.text', $this->getControlName('Message'), $this->get('message'), 'name="message" size="30" maxlength="255" placeholder="'.JText::_('Message').'"');

        // workaround: if nothing is selected, the element is still being transfered
        $html[] = '<input type="hidden" name="'.$this->getControlName('select').'" value="1" />';

        return implode("\n", $html);
    }

    return JText::_("There are no options to choose from.");
}
public function hasValue($params = array()) {

    $message = $this->get('message');
    return !empty($message);
}
}
4

1 回答 1

0

尝试改变:

$message         = $this->get('message');

$message         = $this->config->get('message');
于 2012-07-31T00:13:30.037 回答