I'm building a Joomla component and want a specific field (listtype) in component. In administrator/component/com_test/models/forms/testfield.xml I've following code:
<field
name="test"
type="testfield"
label="JOPTION_FILTER_TESTFIELD_LABEL"
description="JOPTION_FILTER_TESTFIELD_DESC"
id="testfield"
class="inputbox"
/>
In administrator/component/com_test/models/fields/testfield.php I've following code:
JFormHelper::loadFieldClass('list');
/**
* Test Field class.
*/
class JFormFieldTestField extends JFormField {
protected $type = 'TestField';
public function getInput() {
return '<select id="'.$this->id.'" name="'.$this->name.'">'.
'<option value="">select test</option>'.
'<option value="1">test1</option>'.
'<option value="2">test2</option>'.
'<option value="3">test3</option>'.
'</select>';
}
}
In administrator/component/com_test/views/tests/tmpl/default.php I've created a column 'test':
<td class="small hidden-phone">
<?php echo $item->test; ?>
</td>
I've a problem to save data 1,2,3 to database and second I want that in stead of the values 1,2,3 as saved into the database, the values ‘test1’, ‘test2’, ‘test3’ will be reproduced in this column. I've tried several things (e.g. with JTEXT in 'testfield.php'), but until now I didn't manage to find the correct code. Can anyone help me further?