Thanks for the further info.
On Mar 22, 10:29 am, "GreyCells" <[EMAIL PROTECTED]> wrote:
> If I understand you correctly, you'd like to add model attributes that
> can be used by the model internally (for validation etc), but not
> persisted to the database?
>
> All model data is stored as an associative array (a public attribute)
> in the model as $this->data['ModelName']['field_name'], so you can
> either directly insert into that array (from within a controller:
> $this->Model->data['ModelName']['field_name'] = 'Some Value'; ) , or
> use $this->Model->set('field_name', 'Some Value'); (again, assuming
> you're setting from the controller). All of this data is available to
> $model->validates().
>
> You must create the model data array first:
> $this->Model->create([$modelData]) for a new record, and/or $this->Model-
> >set($modelData) for an existing record (where $modelData has already
>
> been retrieved via $this->Model->find() or comes from the controller-
>
> >data ) . Note that model->set has two ways of being used.
>
> If you create a form field 'Model/my_checkbox' this will be in the
> controllers data array - which is the same structure as the model data
> array so can be used as per the $modelData above.
>
> HTH
>
> ~GreyCells
>
> On Mar 21, 12:21 am, "Justin Hernandez" <[EMAIL PROTECTED]> wrote:
>
> > How can I add variables to a model without having a corresponding
> > field in the table? I'm looking for something like the attr_accessor
> > in RoR. Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---