Joomla 4 backend form and JSON data

155 views
Skip to first unread message

Steve C

unread,
Jun 7, 2022, 1:12:54 PM6/7/22
to Joomla! General Development
I am trying to convert a J3 Component, I have it about 95% done, All the front end views show the data as desired. When I try to edit the data in the back end my form shows the field set but in its JSON format.

This is my fieldset 

<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'training', 'Training & PTO'); ?>
        <div class="row">
            <div class="col-md-12">
                <fieldset id="training" class="adminform">
                    <?php
                        $this->fieldset = 'training';
                        $html = LayoutHelper::render('joomla.edit.fieldset', $this);
                        echo $html;
                    ?>
                </fieldset>
            </div>
        </div>

Here is a pic of the result for the PTO 
PTO.png

I tried to use JSON_ENCODE on the $html output but it just out put \n \t instead of the data. 
If anyone can point me in the right direction, I would appreciate it.
Steve

Glenn Arkell

unread,
Jun 7, 2022, 8:13:44 PM6/7/22
to Joomla! General Development
This is the format I use for the backend edit screen.  Hope it helps.  Cheers.
    <?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'general', Text::_('COM_MYCOMPONENT_TAB_TRANSACTION', true)); ?>

        <div class="row-fluid">
            <div class="span12 form-horizontal">
                <fieldset name="general" class="adminform">
                    <legend><?php echo Text::_('COM_MYCOMPONENT_FIELDSET_TRANSACTION'); ?></legend>
                    <?php echo $this->form->renderFieldset('general'); ?>
                </fieldset>
            </div>
        </div>

    <?php echo HTMLHelper::_('uitab.endTab'); ?>
And then in the xml form definition I have the fieldset defined as:

    <fieldset name="general">

        <field name="tran_desc" filter="safehtml" type="text" label="COM_MYCOMPONENT_FORM_LBL_TRANSACTION_TRAN_DESC" description="COM_MYCOMPONENT_FORM_DESC_TRANSACTION_TRAN_DESC" hint="COM_MYCOMPONENT_FORM_LBL_TRANSACTION_TRAN_DESC"/>

    </fieldset>
 

Steve C

unread,
Jun 8, 2022, 7:26:12 AM6/8/22
to Joomla! General Development
Thanks Glenn
I will give it a try and see if it works.

Steve

Reply all
Reply to author
Forward
0 new messages