Reputation: 11
I am saving form data in a Session, and trying to save to a model called Property using the session array. Please see the array below. I think it has something to do with the Session array but I am not sure.
When I try to save like so, it does not save:
$this->Property->save($propertyData) where $propertyData is the property array.
sql_dump:
INSERT INTO `fra`.`properties` (`type`, `address`, `city`, `state`, `zip`, `price`, `bed_rooms`, `bath_rooms`, `lot_size_sq_ft`)
VALUES ('0', '2720 Acapulco way', 'modesto', 'ca', '95355', 310000, 4, 3, 6040)
The session array is:
Array
(
[house_details] => Array
(
[form] => Array
(
[section] => house_details
)
[Property] => Array
(
[type] => 0
[address] => 2720 Acapulco way
[city] => modesto
[state] => ca
[zip] => 95355
[price] => 310000
[prop_year_build] => 2007
[prop_year_remodel] =>
[bed_rooms] => 4
[bath_rooms] => 3
[garage_spaces] => 3
[lot_size_sq_ft] => 6040
[house_size_sq_ft] => 3720
[stories] => 2
[condition_rating] => 8
)
Upvotes: 1
Views: 111
Reputation: 14544
You should be able to do this quite simply. You probably have a problem with $propertyData
being set as the wrong thing so it doesn't provide a valid value for the model save.
What do you get if you do debug($propertyData)
?
Does this work?
$propertyData = $this->Session->read('house_details.Property');
$this->Property->save(propertyData);
Upvotes: 1