Great, so now when I need to build my view that displays data from
four different models, I can call set a bunch of times in the
controller for each model. come up with a whole new form helper to
deal with data that does not have a model key. And deal with duplicate
fields labeled 'id' in my html f
One slight change: you're $model param is superfluous. There's no need
to pass the model as this is the AppModel. Just use $this when
referencing it.
I'd also check if $this->data exists before doing anything.
OK, one other possibility:
public function data()
{
if (empty($this->data)) re
Just in case somebody is interested... I have added a small method
data() that works a little nicer in my opinion than the standard way
of accessing the data array's values is...
So instead of $this->Model->data['User']['name'] you can just call
$this->Model->data('name')... saves you a few keystr
On Tue, Oct 19, 2010 at 7:03 PM, cricket wrote:
> On Tue, Oct 19, 2010 at 5:53 AM, psybear83 wrote:
>> Hi everybody
>>
>> Sorry for this newbish question, but I don't seem to find much about
>> this (although I should, I guess).
>>
>> $m = $this->Model->find(1);
>
> Since when does find() work li
On Tue, Oct 19, 2010 at 8:30 AM, Joshua Muheim wrote:
>
> Then I saw that every related model has its own key there, so it makes
> a bit sense. But why is the key in the array the model's name?
> Wouldn't it be better to have the name of the association in there?
What if you have several other mo
On Tue, Oct 19, 2010 at 5:53 AM, psybear83 wrote:
> Hi everybody
>
> Sorry for this newbish question, but I don't seem to find much about
> this (although I should, I guess).
>
> $m = $this->Model->find(1);
Since when does find() work like that? What version are you using?
> echo $m->data['Model
You can use read.
$this->read('column');
If the data doesnt exist yet, pass an ID.
$this->read('column', $id);
But usually best to just grab the who result, then use read()
afterwards.
On Oct 19, 8:40 am, Joshua Muheim wrote:
> Accepted. :-) Thanks for your opinion.
>
> On Tue, Oct 19, 2010 a
Accepted. :-) Thanks for your opinion.
On Tue, Oct 19, 2010 at 5:37 PM, Jeremy Burns | Class Outfit
wrote:
> I hate to be contrary, but I disagree. Whatever else you come up with would
> be great for some, awkward for others. It works and I think it's very precise.
>
> Jeremy Burns
> Class Outfi
I hate to be contrary, but I disagree. Whatever else you come up with would be
great for some, awkward for others. It works and I think it's very precise.
Jeremy Burns
Class Outfit
jeremybu...@classoutfit.com
http://www.classoutfit.com
On 19 Oct 2010, at 16:34, Joshua Muheim wrote:
> Thanks fo
Thanks for your explanations, sounds good. Still I think
$model->data['Model']['field'] is very awkward. ;-)
On Tue, Oct 19, 2010 at 4:26 PM, Jeremy Burns | Class Outfit
wrote:
> I think this is a mute point - it works really well as it is.
>
> If a model has a self join relationship with itself
I think this is a mute point - it works really well as it is.
If a model has a self join relationship with itself you give it a different
model alias, so it will appear with that name in the data array, not the name
of the model. For example, an employees table might have a self join to denote
Ah, and yes, I trust in these guys, don't worry! :-) I'm only trying
to figure out why things are the way they are so I can learn from
these wise guys.
On Tue, Oct 19, 2010 at 3:59 PM, Joshua Muheim wrote:
> Maybe I don't really understand your point, but as far as I see that's
> exactly what I'v
Maybe I don't really understand your point, but as far as I see that's
exactly what I've written here:
Then I saw that every related model has its own key there, so it makes
a bit sense. But why is the key in the array the model's name?
Wouldn't it be better to have the name of the association in
i think you are missing the obvious point
is there a reason why this is done this way in cake? yes, there is
trust the guys that work with since several years
one example:
you have a BelongsTo relationshop
cake can easily get this data as well
now you can do:
$this->Model->recursive = 0;
$m = $t
It looks really clumsy to me. What about the following?
class AppModel extends Model {
function data($field) {
return $this->data[$this->name][$field];
}
}
First I was not sure why in the $data array there is a key
'ModelName', I would have expected something like this:
array(
nope
but thats already a very neat way to do it
what is your problem with it?
On 19 Okt., 11:53, psybear83 wrote:
> Hi everybody
>
> Sorry for this newbish question, but I don't seem to find much about
> this (although I should, I guess).
>
> $m = $this->Model->find(1);
> echo $m->data['Model'][
Hi everybody
Sorry for this newbish question, but I don't seem to find much about
this (although I should, I guess).
$m = $this->Model->find(1);
echo $m->data['Model']['something];
Is there a better way of getting a model's data fields instead of
this? I always thought this could be done with $m
17 matches
Mail list logo