I'm trying to set up the Media plugin, but am having problems. I have a PressRelease model, and while adding an entry I would like to choose and upload a PDF file to associate with it. But when adding an entry, the press_releases table receives an entry, and the attachment table does not. *If I use the baked Attachment view to add an entry the attachments table DOES receive the row.
I have followed the documentation, updated the bootstrap file, etc. Below is the relevant code from the Press Release model, controller and view. If you have any idea what I correct, please advise. Thanks! A few simple questions also: 1. Do I need to add this ... var $helpers = array('Media.Media'); ... to my PressRelease model? 2. Do I need to add "belongsTo" data to the Attachment model? ------ Code Provided Below ------ The Press Release model has this: var $hasOne = array( 'Attachment' => array( 'className' => 'Media.Attachment', 'foreignKey' => 'foreign_key', 'conditions' => array('Attachment.model' => 'PressRelease'), 'dependent' => true, )); The Press Release controller has this: function admin_add() { $this->layout = 'admin'; if (!empty($this->data)) { $this->PressRelease->create(); if ($this->PressRelease->saveAll($this->data, array('validate' => 'first'))) { $this->Session->setFlash('The press release has been saved.', 'flash_success'); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash('The press release could not be saved. Please, try again.', 'flash_error'); } } $projects = $this->PressRelease->Project->find('list'); $this->set(compact('projects')); } The form in the view looks like this: <div class="pressReleases form"> <?php echo $this->Form->create('PressRelease', array('enctype' => 'multipart/form-data'));?> <fieldset> <legend><?php __('Add Press Release'); ?></legend> <?php $current_year = date('Y'); $max_year = $current_year + 2; $unix_timestamp = strtotime('now'); echo $this->Form->input('date', array('type'=>'date', 'minYear'=>2005, 'maxYear'=>$max_year, 'selected'=>$unix_timestamp)); echo $this->Form->input('title'); echo $this->Form->input('file', array('label' => 'File', 'type' => 'file')); echo $this->Form->input('Project',array('label'=>'Related Project(s)', 'multiple' => 'checkbox')); ?> </fieldset> <?php echo $this->Form->end(__('Add Press Release', true));?> </div> -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php