我正在尝试description
在数据库中保存一个具有 varchar(500) 的字段。当我在 firebug 中查看网络面板时,正在发布整个描述(200 多个字)。然而,在 cakephp 中只保存了 75 个单词。我在控制器中设置了一个断点并查看了 this->request->data,它有大约 150 个字符。下面是我的代码:
<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'));
}
}
}