我試圖保存在數據庫中有varchar(500)的description
字段。當我看着螢火蟲中的Net Panel時,整個描述被張貼出來(超過200個字)。然而,在cakephp中只有75個詞正在保存。我在我的控制器中設置了一個斷點,並查看了這個請求 - >數據,它有大約150個字符。下面是我的代碼:Cakephp2.3文本區未正確發佈
<fieldset>
<legend>Create Log</legend>
<?php echo $this->Form->Create('Log', array('inputDefaults' => array('div' => false, 'label' => false))); ?>
<div class="control-group">
<div class="input-prepend">
<span class="add-on"><i class="icon-folder-open"></i></span>
<?php echo $this->Form->input('project_id'); ?>
</div>
</div>
<div class="control-group">
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input type="text" id="txtName" placeholder="Customer" />
<?php echo $this->Form->Hidden('customer_id'); ?>
<a><span class="add-on"><i class="icon-plus" style="color: green;" onclick="window.open('<?php echo $this->Html->Url(array('controller' => 'customers', 'action' => 'add?popup')); ?>', 'Add Customer', 'height=630, width=430')"></i></span></a>
</div>
</div>
<div class="control-group">
<div class="input-prepend">
<span class="add-on"><i class="icon-time"></i></span>
<?php echo $this->Form->input('time_spent', array('placeholder' => 'Time spent (hrs)')); ?>
</div>
</div>
<div class="control-group">
<div class="input-prepend">
<span class="add-on"><i class="icon-book"></i></span>
<?php echo $this->Form->textarea('description', array('placeholder' => 'Description', 'class' => 'logTextArea', 'rows' => '7')); ?>
</div>
</div>
<?php echo $this->Form->end(array(
'label' => 'Save Record',
'class' => 'btn btn-primary',
'div' => false
)); ?>
<?php echo $this->Html->script('jquery.autocomplete', array('inline' => false)); ?>
<?php $this->start('script'); ?>
<script type="text/javascript">
$(document).ready(function() {
var options, a;
jQuery(function() {
options = {
serviceUrl: "<?php echo $this->Html->Url(array('controller' => 'logs', 'action' => 'autoComplete.json')); ?>",
minChars: 2,
onSelect: function(suggestion){ $('#LogCustomerId').val(suggestion.data); }
};
a = $('#txtName').autocomplete(options);
});
});
</script>
<?php $this->end(); ?>
控制器:
public function add() {
$this->set('title_for_layout', 'Add log');
// Populate projects DDL
$this->set('projects', $this->Log->Project->find('list', array(
'order' => array('Project.project_name')
)));
if ($this->request->is('post'))
{
$this->Log->create();
if ($this->Log->save($this->request->data))
{
$this->Session->setFlash('Log has succesfully been created', 'default', array('class' => 'alert alert-success'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('Unable to save log', 'default', array('class' => 'alert alert-error'));
}
}
}
您的表格定義是什麼樣的?您是否嘗試清除cakephp模型緩存(app/tmp/cache/Models)?另外,將您的調試級別設置爲2並檢查執行了哪些SQL查詢以檢查是否創建了正確的查詢。 – thaJeztah
嗯,對不起,只是意識到我誤解了你的問題,我是否正確理解數據已經在'$ this-> request-> data'內被截斷了?您是否嘗試調試/跟蹤原始的'$ _POST'數據? – thaJeztah
@thaJeztah這是正確的,數據已經被截斷$ this-> request-> data內。我也檢查了原始的$ _POST數據,並在那裏截斷。當你說清除模型緩存時,我應該刪除模型目錄嗎? – Andrew