Hi every:
After a lot of Google hours and finally I found a plugin for handle multiple files uploads. The address for this plugin is this one: http://milesj.me/code/cakephp/uploader#installation. Because I'm newbie with Cake I need your help on some parts. I have a table called "Records" and other called "Documents" and a relationship between them as 1 record can have many documents so it's 1:m. Now in the Model for table Records I have this code:
<?php
App::uses('AppModel', 'Model');
class Record extends AppModel {
public $displayField = 'name';
public $validate = array(
'name' => array(
'notempty' => array(
'rule' => array('notempty'),
'message' => 'The field can not be empty',
),
),
'lastname' => array(
'notempty' => array(
'rule' => array('notempty'),
'message' => 'The field can not be empty',
),
),
'email' => array(
'email' => array(
'rule' => array('email'),
'message' => 'The email address is not valid',
),
),
);
public $belongsTo = array(
'Country' => array(
'className' => 'Country',
'foreignKey' => 'country_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
public $hasMany = array(
'Document' => array(
'className' => 'Document',
'foreignKey' => 'record_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
public $actsAs = array(
'Uploader.Attachment' => array(
'fileName' => array(
'name' => 'formatFileName', // Name of the function to use to format filenames
'dbColumn' => 'uploadPath', // The database column name to save the path to
'importFrom' => '', // Path or URL to import file
'defaultPath' => '', // Default file path if no upload present
'maxNameLength' => 30, // Max file name length
'overwrite' => true, // Overwrite file with same name if it exists
'stopSave' => true, // Stop the model save() if upload fails
'allowEmpty' => true, // Allow an empty file upload to continue
'transforms' => array(), // What transformations to do on images: scale, resize, etc
'metaColumns' => array( // Mapping of meta data to database fields
'ext' => '',
'type' => '',
'size' => '',
'group' => '',
'width' => '',
'height' => '',
'filesize' => ''
)
)
)
);
}
But as I said before the attachment or uploaded files information it's in Documents table and not in Records so my first question around this plugin is: can I save the file related information in the Documents table? If so how? I try to contact the author but at this moment doesn't reply yet.
Cheers and thanks in advance
Ing. Reynier Pérez Mira
--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Saturday, February 25, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment