Поле в xml файле components/my_component/models/forms/
<field name="label_genre" type="sql" class="inputbox" query="SELECT * FROM #__genre" key_field="id" value_field="title" multiple="true" label="COM_CREAT_GENRE_LBL" description="COM_CREAT_GENRE_DESC"> <option value="">COM_SELECT</option> </field>
controllers:
protected function postSaveHook(JModelLegacy $model, $validData = array()) { if(isset($validData['label_genre'])) { $data['label_genre'] = implode(',', $validData['label_genre']); } }
models:
protected function loadFormData() { $data = JFactory::getApplication()->getUserState( 'com_mpc.edit.playlist.data', array() ); if ( empty( $data ) ) { $data = $this->getItem(); } // multiselect if($data->label_genre) { $data->label_genre = explode(',', $data->label_genre); } return $data; }
Добавить в bind функцию в файле tables
if (is_array($array['label_genre'])) { $array['label_genre'] = implode(',',$array['label_genre']); } else if(is_null($array['label_genre'])) { $array['label_genre'] = ''; }