1

嗨,我的问题是当我在 cake php 中提交表单时,它创建了错误的模型对象。

我已经尝试了所有可能的解决方案,但仍然没有成功,请查看我的代码

下面是我的表单 PHP 代码。尽管我得到了竞争对象,但我已经给出了正确的模型名称“报价”。您还可以看到我提交表单时创建的对象。

<?php echo $this->Form->create('Quote', array('type' => 'file')); ?>
 <fieldset>
  <legend><?php echo __('Add Quote'); ?></legend>
 <?php
  echo $this->Form->input('quote');
  echo $this->Form->input('author');
  echo $this->Form->input('file_name',array('type'=>'file'));
  echo $this->Form->input('button_label');
 ?>
 </fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
 <h3><?php echo __('Actions'); ?></h3>
 <ul>

  <li><?php echo $this->Html->link(__('List Quotes'), array('action' => 'index')); ?></li>
 </ul>

在表单提交下面的对象后创建这就是为什么我得到错误未定义索引:竞争

应该创建对象 Quote Object

Competition Object
(
    [actsAs] => Array
        (
            [Sluggable.Sluggable] => Array
                (
                    [label] => title
                    [slug] => slug
                    [separator] => -
                    [overwrite] => 1
                )

            [Containable] => 
            [MeioUpload] => Array
                (
                    [file_name] => Array
                        (
                            [dir] => img{DS}widget_images
                            [create_directory] => 1
                            [allowed_mime] => Array
                                (
                                    [0] => image/jpeg
                                    [1] => image/pjpeg
                                    [2] => image/png
                                    [3] => image/gif
                                )

                            [allowed_ext] => Array
                                (
                                    [0] => .jpg
                                    [1] => .jpeg
                                    [2] => .png
                                    [3] => .JPG
                                    [4] => .JPEG
                                    [5] => .PNG
                                    [6] => .gif
                                    [7] => .GIF
                                )

                            [default] => default.jpg
                        )

                )

        )

    [validate] => Array
        (
            [title] => Array
                (
                    [notEmpty] => Array
                        (
                            [rule] => Array
                                (
                                    [0] => notEmpty
                                )

                        )

                )

            [details] => Array
                (
                    [notEmpty] => Array
                        (
                            [rule] => Array
                                (
                                    [0] => notEmpty
                                )

                        )

                )

            [end_date] => Array
                (
                    [date] => Array
                        (
                            [rule] => Array
                                (
                                    [0] => date
                                )

                        )

                )

            [file_name] => Array
                (
                    [FieldName] => Array
                        (
                            [rule] => Array
                                (
                                    [0] => uploadCheckFieldName
                                )

                            [check] => 1
                            [message] => Este campo não foi definido entre os parâmetros do MeioUploadBehavior.
                        )

                    [Dir] => Array
                        (
                            [rule] => Array
                                (
                                    [0] => uploadCheckDir
                                )

                            [check] => 1
                            [message] => O diretório onde este arquivo seria colocado não existe ou é protegido contra escrita.
                        )

                    [UploadError] => Array
                        (
                            [rule] => Array
                                (
                                    [0] => uploadCheckUploadError
                                )

                            [check] => 1
                            [message] => There was a problem with that upload.
                        )

                    [MaxSize] => Array
                        (
                            [rule] => Array
                                (
                                    [0] => uploadCheckMaxSize
                                )

                            [check] => 1
                            [message] => File exceeds max file size.
                        )

                    [InvalidMime] => Array
                        (
                            [rule] => Array
                                (
                                    [0] => uploadCheckInvalidMime
                                )

                            [check] => 1
                            [message] => Invalid mime type.
                        )

                    [InvalidExt] => Array
                        (
                            [rule] => Array
                                (
                                    [0] => uploadCheckInvalidExt
                                )

                            [check] => 1
                            [message] => Invalid file extension.
                        )

                )

        )

    [hasAndBelongsToMany] => Array
        (
            [User] => Array
                (
                    [className] => User
                    [joinTable] => competitions_users
                    [foreignKey] => competition_id
                    [associationForeignKey] => user_id
                    [unique] => keepExisting
                    [conditions] => 
                    [order] => 
                    [limit] => 
                    [offset] => 
                    [finderQuery] => 
                    [with] => CompetitionsUser
                    [dynamicWith] => 1
                    [fields] => 
                )

        )

    [recursive] => -1
    [useDbConfig] => default
    [useTable] => competitions
    [id] => 
    [data] => Array
        (
        )

    [schemaName] => football_new
    [table] => competitions
    [primaryKey] => id
    [_schema:protected] => Array
        (
            [id] => Array
                (
                    [type] => integer
                    [null] => 
                    [default] => 
                    [length] => 11
                    [key] => primary
                )

            [title] => Array
                (
                    [type] => string
                    [null] => 
                    [default] => 
                    [length] => 255
                    [collate] => latin1_swedish_ci
                    [charset] => latin1
                )

            [promo_title] => Array
                (
                    [type] => string
                    [null] => 
                    [default] => 
                    [length] => 255
                    [collate] => latin1_swedish_ci
                    [charset] => latin1
                )

            [details] => Array
                (
                    [type] => text
                    [null] => 
                    [default] => 
                    [length] => 
                    [collate] => latin1_swedish_ci
                    [charset] => latin1
                )

            [end_date] => Array
                (
                    [type] => date
                    [null] => 
                    [default] => 
                    [length] => 
                )

            [filesize] => Array
                (
                    [type] => integer
                    [null] => 
                    [default..  

请建议我解决方案我很困惑。谢谢

4

0 回答 0