Closed Greyg-POPEI closed 7 years ago
What does your form field look like?
My form use this Angular-JS plugin : ng-file-upload : https://github.com/danialfarid/ng-file-upload
Thank for you answer
A little up
Thank you
Same over here. Did you figure out this issue?
I actually copy most of the code from @Greyg-POPEI (Table structure and relations) and it worked. This is how the form looks like:
//In my case, notes hasMany Attachments. I am attaching the behavior to the field 'file'
//Template/Notes/add.ctp
<?= $this->Form->create($note, ['type' => 'file']) ?>
<fieldset>
<legend><?= __('Add Note') ?></legend>
<?php
echo $this->Form->input('title');
echo $this->Form->input('text');
//attachments
echo $this->Form->input('attachments.0.file', ['type' => 'file']);
echo $this->Form->input('attachments.0.model', ['value' => 'Notes']);
echo $this->Form->input('attachments.1.file', ['type' => 'file']);
echo $this->Form->input('attachments.1.model', ['value' => 'Notes']);
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
cheers!
Seems like it's no issue related to the plugin itselfs.
Hello,
I try to use a polymorphic attachment model like in 2.x (http://cakephp-upload.readthedocs.io/en/2.x/polymorphic.html) in 3.x CakePHP project.
I have the same configuration: Table
documents
(just like your 'attachments
' table). Tableposts
(just like your'posts'
table).When I try to upload my file i get this error :
Cannot insert the value NULL into column 'name', table 'documents'; column does not allow nulls. INSERT fails.
Request data look like this :
My models look like this :
I also look in UploadBehavior.php beforeSave function.
I don't have any error during upload, but the loop break here.
Do you have any ideas what i'm doing wrong ? Any help will be appreciated :)
Thanks