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'));
}
}
}