Well it was just my user error as usual haha. I'll include what I did wrong
and how I fixed it in case someone else makes the same mistakes:
First I forgot to change the News add form to 'file' type when I introduced
the new file upload functionality to the form. I had this set in my stand
alone upload form and that's why it worked there and not here, to some
degree.
Then I forgot to set the Associated fields correctly in the Form input it
should look like this:
$this->Form->input('Upload.0.filename');
Secondly, I didn't have my extension types correctly defined in the
MeioUpload plugin and when I fixed the above errors the validation wouldn't
allow .doc .pdf through and that was because I didn't include the period
along with the allowed extensions.
Solved.
Andrew
On Thursday, September 6, 2012 1:39:42 PM UTC-7, andrewperk wrote:
>
> Hello,
>
> My associated model validation for Uploads(MeioUpload) while saving
> multiple model associations at once does not work.
>
> I'm using the MeioUpload plugin for uploading files. Each Upload is
> related to a News with a one to many relationship. When I try to save an
> Upload at the same time as saving a new News the validation for the Upload
> model doesn't work. My other associated model validations work fine, but
> not the Upload model.
>
> I think this might be because the validation for the Upload model is
> handled by the MeioUpload plugin?
>
> Here's my view:
>
> <?php echo $this->Form->create('News'); ?>
>> <fieldset>
>> <legend><?php echo 'Add News'; ?></legend>
>> <?php
>> echo $this->Form->input('News.member_id');
>> echo $this->Form->input('News.newstype_id');
>> echo $this->Form->input('News.company_id');
>> echo $this->Form->input('News.title');
>> echo $this->Form->input('News.body');
>> echo $this->Form->input('News.alert');
>>
>
>
>> echo $this->Form->input('Company.name');
>>
>
>
>> echo $this->Form->input('Upload.filename', array('type'=>'file'));
>> echo $this->Form->input('Upload.dir', array('type'=>'hidden'));
>> echo $this->Form->input('Upload.mimetype', array('type'=>'hidden'));
>> echo $this->Form->input('Upload.filesize', array('type'=>'hidden'));
>> echo $this->Form->input('Upload.download', array('label'=>'Add to
>> Downloads'));
>> ?>
>> </fieldset>
>> <?php echo $this->Form->end(__('Submit')); ?>
>
>
>
> Here's how I'm saving the data:
>
>
>
>> $this->News->create();
>
> $this->News->saveAll($this->request->data)
>
>
>
> I've also tried $this->News->saveAssociated and tried saving through the
> association like: $this->News->Upload->saveAll($this->request->data). That
> doesn't work either.
>
> The News Model fields all validate and the associated Company Model field
> validates but it does not validate the Upload Model fields. It acts as if
> there's no validation. And when I choose a file to upload and hit the
> Submit button it doesn't remember the file that I chose to upload. It
> completely ignores the Upload fields in the form.
>
> Note: the Upload works perfectly fine on its own while not saving
> associated models. I can upload files and it validates just fine, its only
> when trying to save with associated models.
>
> Any help in identifying what I'm doing wrong is appreciated. Thanks.
>
> Andrew
>
--
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.