Figured it out... it should be:
var $uses = array('Artistsplugin.ArtistspluginMp3');
not
var $uses = array('ArtistspluginMp3');
The second one looks for the model in /app/models/, not /app/plugins/
artistsplugin/models/
Thanks to PhpNut for this explanation.
On Jun 5, 7:19 pm, Sake <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a problem and I think it's due to a bug. I've made a plugin
> called Artistsplugin. The plugin has a controller called
> ArtistspluginMp3sController and a model called ArtistspluginMp3.
>
> here is a stripped down version of my controller class:
>
> class ArtistspluginMp3sController extends ArtistspluginAppController {
>
> var $name = 'ArtistspluginMp3s';
> var $helpers = array('Html', 'Form');
>
> // var $uses = array('ArtistspluginMp3');
>
> function admin_index() {
> print pr($this->ArtistspluginMp3);die();
> }
>
> }
>
> and my model:
>
> <?php
>
> class ArtistspluginMp3 extends ArtistspluginAppModel
> {
> var $name = 'ArtistspluginMp3';
>
> var $belongsTo = 'ArtistspluginArtist';
>
> var $validate = array(
> 'song_title' => array(
> 'minLength' => array(
> 'rule' =>
> array('minLength','2'),
> 'required' => true,
> 'message' => 'Please enter a
> title of at least 2 characters.'
> ),
> 'maxLength' => array(
> 'rule' =>
> array('maxLength','255'),
> 'required' => true,
> 'message' => 'Your title can
> be no longer than 255 characters.'
> ),
> ),
> 'url' => array(
> 'minLength' => array(
> 'rule' =>
> array('minLength','1'),
> 'required' => true,
> 'message' => 'Please enter a
> url.'
> ),
> 'maxLength' => array(
> 'rule' =>
> array('maxLength','255'),
> 'required' => true,
> 'message' => 'Your url can be
> no longer than 255 characters.'
> ),
> ),
>
> );
> var $funtimes = 'fun';
>
> }
>
> Now, the problem here lies in the line that's commented in my
> controller (the $uses variable). If I uncomment it and load the model
> via the $uses variable, my output is different. Below I'll show the
> two outputs. Notice how one contains my validation rules and the other
> doesn't? Also notice the $funtimes variable that I defined, it's not
> in the object when I load it via $uses.
>
> I'm wondering why that is.. My program isn't performing validation for
> my plugin when I load the models using the $uses... This is a big
> problem and I think it's a bug, but I'd like a second opinion. Could
> it be because I have this code in a plugin?
>
> FYI: I tried this on the latest 1.2 beta and then tried it again with
> RC1, problem always exists.
>
> My outputs:
>
> ==================================
> When controller DOESN'T load model via $uses:
> ==================================
>
> ArtistspluginMp3 Object
> (
> [name] => ArtistspluginMp3
> [belongsTo] => Array
> (
> [ArtistspluginArtist] => Array
> (
> [className] => ArtistspluginArtist
> [foreignKey] => artistsplugin_artist_id
> [conditions] =>
> [fields] =>
> [order] =>
> [counterCache] =>
> )
>
> )
>
> [validate] => Array
> (
> [song_title] => Array
> (
> [minLength] => Array
> (
> [rule] => Array
> (
> [0] => minLength
> [1] => 2
> )
>
> [required] => 1
> [message] => Please enter a title of at
> least 2 characters.
> )
>
> [maxLength] => Array
> (
> [rule] => Array
> (
> [0] => maxLength
> [1] => 255
> )
>
> [required] => 1
> [message] => Your title can be no longer
> than 255 characters.
> )
>
> )
>
> [url] => Array
> (
> [minLength] => Array
> (
> [rule] => Array
> (
> [0] => minLength
> [1] => 1
> )
>
> [required] => 1
> [message] => Please enter a url.
> )
>
> [maxLength] => Array
> (
> [rule] => Array
> (
> [0] => maxLength
> [1] => 255
> )
>
> [required] => 1
> [message] => Your url can be no longer
> than 255 characters.
> )
>
> )
>
> )
>
> [funtimes] => fun
> [useDbConfig] => default
> [useTable] => artistsplugin_mp3s
> [displayField] => id
> [id] =>
> [data] => Array
> (
> )
>
> [table] => artistsplugin_mp3s
> [primaryKey] => id
> [_schema] => Array
> (
> [id] => Array
> (
> [type] => integer
> [null] =>
> [default] =>
> [length] => 11
> [key] => primary
> )
>
> [created] => Array
> (
> [type] => datetime
> [null] =>
> [default] =>
> [length] =>
> )
>
> [modified] => Array
> (
> [type] => datetime
> [null] =>
> [default] =>
> [length] =>
> )
>
> [artistsplugin_artist_id] => Array
> (
> [type] => integer
> [null] =>
> [default] =>
> [length] => 11
> )
>
> [song_title] => Array
> (
> [type] => string
> [null] =>
> [default] =>
> [length] => 255
> )
>
> [url] => Array
> (
> [type] => string
> [null] =>
> [default] =>
> [length] => 255
> )
>
> )
>
> [validationErrors] => Array
> (
> )
>
> [tablePrefix] =>
> [alias] => ArtistspluginMp3
> [tableToModel] => Array
> (
> [artistsplugin_mp3s] => ArtistspluginMp3
> [artistsplugin_artists] => ArtistspluginArtist
> )
>
> [logTransactions] =>
> [transactional] =>
> [cacheQueries] =>
> [hasOne] => Array
> (
> )
>
> [hasMany] => Array
> (
> )
>
> [hasAndBelongsToMany] => Array
> (
> )
>
> [actsAs] =>
> [Behaviors] => BehaviorCollection Object
> (
> [modelName] => ArtistspluginMp3
> [_attached] => Array
> (
> )
>
> [_disabled] => Array
> (
> )
>
> [__methods] => Array
> (
> )
>
> [__mappedMethods] => Array
> (
> )
>
> [_log] =>
> )
>
> [whitelist] => Array
> (
> )
>
> [cacheSources] => 1
> [findQueryType] =>
> [recursive] => 1
> [order] =>
> [__exists] =>
> [__associationKeys] => Array
> (
> [belongsTo] => Array
> (
> [0] => className
> [1] => foreignKey
> [2] => conditions
> [3] => fields
> [4] => order
> [5] => counterCache
> )
>
> [hasOne] => Array
> (
> [0] => className
> [1] => foreignKey
> [2] => conditions
> [3] => fields
> [4] => order
> [5] => dependent
> )
>
> [hasMany] => Array
> (
> [0] => className
> [1] => foreignKey
> [2] => conditions
> [3] => fields
> [4] => order
> [5] => limit
> [6] => offset
> [7] => dependent
> [8] => exclusive
> [9] => finderQuery
> [10] => counterQuery
> )
>
> [hasAndBelongsToMany] => Array
> (
> [0] => className
> [1] => joinTable
> [2] => with
> [3] => foreignKey
> [4] => associationForeignKey
> [5] => conditions
> [6] => fields
> [7] => order
> [8] => limit
> [9] => offset
> [10] => unique
> [11] => finderQuery
> [12] => deleteQuery
> [13] => insertQuery
> )
>
> )
>
> [__associations] => Array
> (
> [0] => belongsTo
> [1] => hasOne
> [2] => hasMany
> [3] => hasAndBelongsToMany
> )
>
> [__backAssociation] => Array
> (
> )
>
> [__insertID] =>
> [__numRows] =>
> [__affectedRows] =>
> [__findMethods] => Array
> (
> [all] => 1
> [first] => 1
> [count] => 1
> [neighbors] => 1
> [list] => 1
> )
>
> [_log] =>
> [ArtistspluginArtist] => AppModel Object
> (
> [useDbConfig] => default
> [useTable] => artistsplugin_artists
> [displayField] => name
> [id] =>
> [data] => Array
> (
> )
>
> [table] => artistsplugin_artists
> [primaryKey] => id
> [_schema] => Array
> (
> [id] => Array
> (
> [type] => integer
> [null] =>
> [default] =>
> [length] => 11
> [key] => primary
> )
>
> [created] => Array
> (
> [type] => datetime
> [null] =>
> [default] =>
> [length] =>
> )
>
> [modified] => Array
> (
> [type] => datetime
> [null] =>
> [default] =>
> [length] =>
> )
>
> [name] => Array
> (
> [type] => string
> [null] =>
> [default] =>
> [length] => 255
> )
>
> )
>
> [validate] => Array
> (
> )
>
> [validationErrors] => Array
> (
> )
>
> [tablePrefix] =>
> [name] => ArtistspluginArtist
> [alias] => ArtistspluginArtist
> [tableToModel] => Array
> (
> [artistsplugin_artists] => ArtistspluginArtist
> )
>
> [logTransactions] =>
> [transactional] =>
> [cacheQueries] =>
> [belongsTo] => Array
> (
> )
>
> [hasOne] => Array
> (
> )
>
> [hasMany] => Array
> (
> )
>
> [hasAndBelongsToMany] => Array
> (
> )
>
> [actsAs] =>
> [Behaviors] => BehaviorCollection Object
> (
> [modelName] => ArtistspluginArtist
> [_attached] => Array
> (
> )
>
> [_disabled] => Array
> (
> )
>
> [__methods] => Array
> (
> )
>
> [__mappedMethods] => Array
> (
> )
>
> [_log] =>
> )
>
> [whitelist] => Array
> (
> )
>
> [cacheSources] => 1
> [findQueryType] =>
> [recursive] => 1
> [order] =>
> [__exists] =>
> [__associationKeys] => Array
> (
> [belongsTo] => Array
> (
> [0] => className
> [1] => foreignKey
> [2] => conditions
> [3] => fields
> [4] => order
> [5] => counterCache
> )
>
> [hasOne] => Array
> (
> [0] => className
> [1] => foreignKey
> [2] => conditions
> [3] => fields
> [4] => order
> [5] => dependent
> )
>
> [hasMany] => Array
> (
> [0] => className
> [1] => foreignKey
> [2] => conditions
> [3] => fields
> [4] => order
> [5] => limit
> [6] => offset
> [7] => dependent
> [8] => exclusive
> [9] => finderQuery
> [10] => counterQuery
> )
>
> [hasAndBelongsToMany] => Array
> (
> [0] => className
> [1] => joinTable
> [2] => with
> [3] => foreignKey
> [4] => associationForeignKey
> [5] => conditions
> [6] => fields
> [7] => order
> [8] => limit
> [9] => offset
> [10] => unique
> [11] => finderQuery
> [12] => deleteQuery
> [13] => insertQuery
> )
>
> )
>
> [__associations] => Array
> (
> [0] => belongsTo
> [1] => hasOne
> [2] => hasMany
> [3] => hasAndBelongsToMany
> )
>
> [__backAssociation] => Array
> (
> )
>
> [__insertID] =>
> [__numRows] =>
> [__affectedRows] =>
> [__findMethods] => Array
> (
> [all] => 1
> [first] => 1
> [count] => 1
> [neighbors] => 1
> [list] => 1
> )
>
> [_log] =>
> )
>
> )
>
> ==================================
> When controller DOES load model via $uses:
> ==================================
>
> AppModel Object
> (
> [useDbConfig] => default
> [useTable] => artistsplugin_mp3s
> [displayField] => id
> [id] =>
> [data] => Array
> (
> )
>
> [table] => artistsplugin_mp3s
> [primaryKey] => id
> [_schema] => Array
> (
> [id] => Array
> (
> [type] => integer
> [null] =>
> [default] =>
> [length] => 11
> [key] => primary
> )
>
> [created] => Array
> (
> [type] => datetime
> [null] =>
> [default] =>
> [length] =>
> )
>
> [modified] => Array
> (
> [type] => datetime
> [null] =>
> [default] =>
> [length] =>
> )
>
> [artistsplugin_artist_id] => Array
> (
> [type] => integer
> [null] =>
> [default] =>
> [length] => 11
> )
>
> [song_title] => Array
> (
> [type] => string
> [null] =>
> [default] =>
> [length] => 255
> )
>
> [url] => Array
> (
> [type] => string
> [null] =>
> [default] =>
> [length] => 255
> )
>
> )
>
> [validate] => Array
> (
> )
>
> [validationErrors] => Array
> (
> )
>
> [tablePrefix] =>
> [name] => ArtistspluginMp3
> [alias] => ArtistspluginMp3
> [tableToModel] => Array
> (
> [artistsplugin_mp3s] => ArtistspluginMp3
> )
>
> [logTransactions] =>
> [transactional] =>
> [cacheQueries] =>
> [belongsTo] => Array
> (
> )
>
> [hasOne] => Array
> (
> )
>
> [hasMany] => Array
> (
> )
>
> [hasAndBelongsToMany] => Array
> (
> )
>
> [actsAs] =>
> [Behaviors] => BehaviorCollection Object
> (
> [modelName] => ArtistspluginMp3
> [_attached] => Array
> (
> )
>
> [_disabled] => Array
> (
> )
>
> [__methods] => Array
> (
> )
>
> [__mappedMethods] => Array
> (
> )
>
> [_log] =>
> )
>
> [whitelist] => Array
> (
> )
>
> [cacheSources] => 1
> [findQueryType] =>
> [recursive] => 1
> [order] =>
> [__exists] =>
> [__associationKeys] => Array
> (
> [belongsTo] => Array
> (
> [0] => className
> [1] => foreignKey
> [2] => conditions
> [3] => fields
> [4] => order
> [5] => counterCache
> )
>
> [hasOne] => Array
> (
> [0] => className
> [1] => foreignKey
> [2] => conditions
> [3] => fields
> [4] => order
> [5] => dependent
> )
>
> [hasMany] => Array
> (
> [0] => className
> [1] => foreignKey
> [2] => conditions
> [3] => fields
> [4] => order
> [5] => limit
> [6] => offset
> [7] => dependent
> [8] => exclusive
> [9] => finderQuery
> [10] => counterQuery
> )
>
> [hasAndBelongsToMany] => Array
> (
> [0] => className
> [1] => joinTable
> [2] => with
> [3] => foreignKey
> [4] => associationForeignKey
> [5] => conditions
> [6] => fields
> [7] => order
> [8] => limit
> [9] => offset
> [10] => unique
> [11] => finderQuery
> [12] => deleteQuery
> [13] => insertQuery
> )
>
> )
>
> [__associations] => Array
> (
> [0] => belongsTo
> [1] => hasOne
> [2] => hasMany
> [3] => hasAndBelongsToMany
> )
>
> [__backAssociation] => Array
> (
> )
>
> [__insertID] =>
> [__numRows] =>
> [__affectedRows] =>
> [__findMethods] => Array
> (
> [all] => 1
> [first] => 1
> [count] => 1
> [neighbors] => 1
> [list] => 1
> )
>
> [_log] =>
> )
>
> ==================================
>
> Thanks for any information on this problem!
>
> -Eduardo
--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---