0
我有這個聯繫表單,它也與其他一些HABTM關係表有關。它們以表格或複選框的形式顯示。我想要的是能夠在仍然以表單的形式選擇那些適用於我添加的聯繫人的情況下搜索它們。我不知道如何做到這一點 - 想着也許是Javascript?通過HABTM複選框/列表搜索
我正在談論的一個例子就像Facebook在通過朋友列表進行搜索時一樣。
下面是聯繫人型號的HABTM關係:
public $hasAndBelongsToMany = array(
'Company' => array(
'className' => 'Company',
'joinTable' => 'companies_contacts',
'foreignKey' => 'contact_id',
'associationForeignKey' => 'company_id',
'unique' => 'keepExisting',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
),
'Event' => array(
'className' => 'Event',
'joinTable' => 'contacts_events',
'foreignKey' => 'contact_id',
'associationForeignKey' => 'event_id',
'unique' => 'keepExisting',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
),
'Screenoccupation' => array(
'className' => 'Screenoccupation',
'joinTable' => 'contacts_screenoccupations',
'foreignKey' => 'contact_id',
'associationForeignKey' => 'screenoccupation_id',
'unique' => 'keepExisting',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
),
'Tapearchive' => array(
'className' => 'Tapearchive',
'joinTable' => 'contacts_tapearchives',
'foreignKey' => 'contact_id',
'associationForeignKey' => 'tapearchive_id',
'unique' => 'keepExisting',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
),
'Relation' => array(
'className' => 'Contact',
'joinTable' => 'contacts_contacts',
'foreignKey' => 'contact_id',
'associationForeignKey' => 'related_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
不知道我需要什麼其他代碼給你看你們,所以請不要讓我知道需要什麼樣的代碼,我將它們添加到這題。
謝謝!
謝謝你。第一個似乎適合我的需求,但我有一些麻煩讓它工作。你能幫我麼? 這是我有的HABTM選擇,我希望它使用該jquery插件。 ('type'=>'select','multiple'=>'select'));};}};} \t?> 有什麼想法? – jase89 2012-08-05 10:37:52
只需在php中創建一個標準多選,然後調用將轉換它的javascript。 – 2012-08-05 10:57:19
對不起ALS,我不知道該怎麼做...這段代碼:<?php echo $ this-> Form-> input('Event',array('type'=>'select','multiple'=> '選擇')); ?>自動創建一個多選。不知道如何去做,否則... – jase89 2012-08-05 11:15:57