1

我正在尝试向表单块添加的问题添加“帮助文本”。像这样的东西,但在表单的前端部分。

由于某种原因,它没有保存值或将值放入编辑表单。即使我手动将它添加到行中,它也不在前端输出中。

我制作了一个自定义表单块/模板,并对以下内容进行了额外更改:

db.xml 中的额外表列“helptext”。并更新了区块。

<table name="btFormQuestions">
...
  <field name="helptext" type="text">
  <default value=""/>
</field>
...
</table>

编辑表单上的一个额外字段(正常和编辑):

<div class="form-group">
  <?php echo $form->label('helptext', t('Help Text'))?>
  <?php echo $form->text('helptext', array('maxlength' => '255'))?>
</div>

在 view.php 中输出

use \Application\Block\Form\MiniSurvey;
...
<?php  echo $question['helptext']; ?>

在 auto.js 中添加了额外的代码,

addQuestion:
postStr += '&helptext=' + encodeURIComponent($('#helptext' + mode).val());
...
reloadQuestion:
$('#helptextEdit').val(jsonObj.helptext);
...
resetQuestion:
$('#helptext').val('');

迷你调查.php,

        $dataValues = array(
            intval($values['qsID']),
            trim($values['question']),
            trim($values['helptext']),
            $values['inputType'],
            $values['options'],
            intval($values['position']),
            $width,
            $height,
            intval($values['required']),
            $values['defaultDate'],
            intval($values['msqID']),
        );
        $sql = 'UPDATE btFormQuestions SET questionSetId=?, question=?, helptext=?, inputType=?, options=?, position=?, width=?, height=?, required=?, defaultDate=? WHERE msqID=? AND bID=0';
    } else {
        if (!isset($values['position'])) {
            $values['position'] = 1000;
        }
        if (!intval($values['msqID'])) {
            $values['msqID'] = intval($this->db->fetchColumn("SELECT MAX(msqID) FROM btFormQuestions") + 1);
        }
        $dataValues = array(
            $values['msqID'],
            intval($values['qsID']),
            trim($values['question']),
            trim($values['helptext']),
            $values['inputType'],
            $values['options'],
            intval($values['position']),
            intval($values['width']),
            intval($values['height']),
            intval($values['required']),
            $values['defaultDate'],
        );
        $sql = 'INSERT INTO btFormQuestions (msqID,questionSetId,question,helptext,inputType,options,position,width,height,required,defaultDate) VALUES (?,?,?,?,?,?,?,?,?,?,?)';
        }
$result = $this->db->executeQuery($sql, $dataValues);

清除缓存并更新块。

Concrete5 上的论坛帖子与更改


已解决: 在 C5 的全新安装上运行。

小改动:

将混凝土/块/表单中的原始文件添加到应用程序文件夹(并更改了命名空间)

db.xml(不需要长文本)

<field name="helptext" type="text" size="65535"></field>

auto.js(分号;在原始的concrete/block/form/auto.js(以及应用程序中的副本)中缺失)

reloadQuestion: 
$('#editQuestionForm').css('display', 'block');
4

0 回答 0