I have a Multi SELECT List
where admin can select more thatn one positions for the player where a player can play
/com/models/forms/player.xml
<field name="sec_position_name" type="checkboxes" label="Secondary Pos." >
<option value="Left">Left</option>
<option value="Middle">Middle</option>
<option value="Right">Right</option>
</field>
And these are the functions in
com/models/player.php that loads the Form data
protected function loadFormData() {
$data = JFactory::getApplication()->
getUserState('com_football.edit.player.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
public function getForm($data = array(), $loadData = true) {
$form = $this->loadForm('com_football.player',
'player', array('control' => 'jform',
'load_data' => $loadData));
return $form;
}
And here is how form is displayed in the Layout.
com/views/player/tmpl/edit.php
<ul class="adminformlist">
<?php foreach ($this->form->getFieldset('optional') as $field): ?>
<li><?php echo $field->label; ?>
<?php echo $field->input; ?></li>
<?php endforeach ?>
</ul>
How can I display already existing values from DB as SELECTED...???
Note: I have asked here too(maybe this clears more)
Write method which get already existing values from database. Let's say it returns an array with values. Next step is to create field by custom type and there get existing values and compare with new values in a loop