First, I apologize if I don't use proper terminology with this
question, but I'm fairly new to Cake and still learning :)
I am developing a website for a Real Estate company - the main part of
this site is a section that focuses on the companies "Listings". A
"Listing" is a house, condo, or parcel of land, that's offered for
sale, along with the details such as price, address, description, etc.
All of this information is stored in a table, named "listings".
One detail that's associated with all Listings is the "View". Here are
the possible values:
- City
- City Lights
- Garden
- Jungle
- Ocean
- Pool
- Street
It's possible, however, that each Listing can have multiple Views.
Here is where I'm having a problem...
There are 3 tables total:
- listings
- propviews (id, name)
- listings_propviews (listing_id, propview_id)
On the "edit" view I have a multiple select box, which is pulling in
the values from the "propview" table correctly.
The associations of listings to propviews are being stored properly in
the listings_propviews table.
The problem I'm having is determining how to get the propviews to be
selected by default when the "edit" view loads. Obviously, when my
client edits a listing I the propviews that have been associated with
the listing need to be pre-selected so they know...
listing model
===================
var $hasAndBelongsToMany = array(
'Propview' => array(
'className' => 'Propview',
'joinTable' => 'listings_propviews',
'foreignKey' => 'listing_id',
'associationForeignKey' => 'propview_id'
),
);
propview model
===================
var $hasAndBelongsToMany = array(
'Listing' => array(
'className' => 'Listing',
'joinTable' => 'listings_propviews',
'foreignKey' => 'propview_id',
'associationForeignKey' => 'listing_id'
)
);
listings controller
===================
$this->set('propviews', $this->Listing->Propview->find('list'));
edit view
===================
<?php echo $this->Form->input('Propview.Propview'); ?>
Please help me!!
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php