Q:

Custom formfield for core component

I’m writing a small plugin for Joomla 3.2, that should extend a core component (com_content), so it shows custom form-fields in the backend additionally, when creating an article.
I followed the instructions from the docs, but unfortunately it doesn’t work out at all. The form-fields show up in the backend as they should, but when I enter something and hit save, then the values doesn’t get stored in the DB.
test123.php
    <?php
    defined ( '_JEXEC' ) or die ( 'Restricted access' );

    class plgContentTest123 extends JPlugin {

            protected $autoloadLanguage = true;

            function onContentPrepareForm($form, $data) {
                    $app = JFactory::getApplication();
                    $option = $app->input->get('option');

                    switch($option) {
                            case 'com_content':
                            if ($app->isAdmin()) {
                                    JForm::addFormPath(__DIR__ . '/forms');
                                    $form->loadFile('content', false);
                            }
                            return true;
                    }
                    return true;
            }
    }
    ?>

forms/content.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <form>
            <fields name="params" >
                    <fieldset name="params" >
                            <field
                                    name="test123"
                                    type="text"
                                    label="Test Field"
                                    />
                            <field
                                    name="test234"
                                    type="text"
                                    label="Another one"
                                    filter="email"
                            />
                    </fieldset>
            </fields>
    </form>

However, I am able to replace previously existing form-fields with the XML-file – these values are stored correctly. (Besides, I noticed, that the $reset parameter of Jform::loadFile (See docs) doesn’t have any effect. No matter, if it’s true or false, the formfields are always replaced.)
I have absolutely no clue what’s going on here…!? So does anyone?

A:

I found a solution to the problem. Just for future reference:
The reason, why the tutorial does not apply to com_content is, that the __content-table in the database has no fields "params" (in contrast to the __contact_details-table, which is used in the tutorial).
So either you will have to alter the table and add a column. However, there is a better solution: Since all parameters from the fieldsets are stored as JSON-encoded strings in the database, you can just simply hook up into an existing fieldset with your custom parameters:
<?xml version="1.0" encoding="UTF-8"?>
<form>
        <fields name="urls" >
                <fieldset name="urls" >
                        <field
                                name="test123"
                                type="text"
                                label="Test Field"
                                />
                        <field
                                name="test234"
                                type="text"
                                label="Another one"
                                filter="email"
                        />
                </fieldset>
        </fields>
</form>

