【问题标题】:Some Form Data Is Not Being Posted To The Database某些表单数据未发布到数据库
【发布时间】:2014-11-26 09:50:17
【问题描述】:

所以,我遇到了一个小问题,我不知道出了什么问题。我有一些数据需要添加到表单和数据库中。我创建了数据库字段,使用varchar 数据类型将其命名为“visit_nature”,然后继续创建表单字段。

<div class="controls-row" id="visitNature">
  <div class="span2">
  <?php echo $this->Form->label('visit_nature', 'Symptomatic or Asymptomatic', array('class'=>'required')); ?>
  </div>
  <div class="span10">
  <?php 
    echo $this->Form->input('visit_nature', array(
         'options' => array('Symptomatic' => 'Symptomatic', 
                            'Asymptomatic' => 'Asymptomatic'),
         'empty' => '--Select Vist Nature--',
         'class'=>'validate[required]',
         ));
    ?>
  <span class="help-inline">Does the patient have symptoms or not</span>
  </div>
</div> 

现在,有趣的是,当您检查网络请求时,来自那里的数据是可见的,但它从未进入数据库,表单上的其他字段已发布。 这些都显示了

_method:"POST",data[PatientVisit][patient_id]:"784"data[PatientVisit][visit_nature]:"Symptomatic"

为什么不将数据发送到数据库?!

【问题讨论】:

  • 回显您的 SQL 查询。所有数据都存在吗?
  • 谢谢@Abhishek 我不知何故忘记了我必须清除 tmp 文件夹中的缓存。终于成功了。

标签: php cakephp


【解决方案1】:

您使用了错误的选择选项。我不肯定这是你的错误来源,但它应该是这样的:

<?php 
echo $this->Form->input('visit_nature', array(
     'options' => array('Symptomatic', 'Asymptomatic'),
     'empty' => '--Select Vist Nature--',
     'class'=>'validate[required]',
     ));
?>

【讨论】:

  • 前一个效果很好。我只需要在 app/tmp/cache 中清除缓存。
猜你喜欢
  • 2012-06-28
  • 2012-05-17
  • 1970-01-01
  • 2018-07-28
  • 2014-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多