I've created a custom field for a module which gets some information from the database. I need to add the functionality to update the information in database if I make some changes.

Here is the code for my custom field which currently only gets the data from the database:

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

$app        = JFactory::getApplication();

class JFormFieldAddlinks extends JFormField {

    protected $type = 'Addlinks';

    // getLabel() left out

    protected function getInput() {
        $html = '';
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select($db->quoteName(array('id', 'link_id', 'image', 'link')));

        // Reset the query using our newly populated query object.
        $row = $db->loadRowList();

        foreach ($row as $key) {
            $html .= "<div class='group' style='clear:both;'>";
            $html .= "<input type='text' name='link' value='$key[2]'>";
            $html .= "<input type='text' name='image' value='$key[3]'>";
            $html .= "</div>";

        return $html;

    public function getLabel() {


XML file:

    <fields name="params"> 
        <fieldset name="addlinks" label="Add Link" addfieldpath="/modules/mod_links/elements">
            <field type="addlinks" name="link"></field>
  • Does this module works only in the backend? Or you want to update information from the frontend? Jan 30 '15 at 7:07
  • this module works only on backend, but now problem solved, thx for feedback
    – Bob Dylan
    Feb 1 '15 at 13:58
  • 3
    Please post your answer to close the question. Feb 23 '15 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.