Cakephp2.3文本区域未正确发布

时间:2013-04-15 13:49:18

标签: php cakephp-2.3

我正在尝试在数据库中保存具有varchar(500)的description字段。当我在firebug中查看Net Panel时,整个描述都被发布(200多个单词)。然而,在cakephp中只保存了75个单词。我在控制器中设置了一个断点并查看了这个> request->数据,它有大约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'));
        }
    }
}

1 个答案:

答案 0 :(得分:1)

此问题可能是由某些版本的PHP中的错误引起的,该错误会截断$_POST个值。

如果不重新发布信息,此问题还包含一些其他信息 信息。

PHP $_POST array variables are truncated

一些(可能)相关的错误;

Bug #42824 Post Data truncated