2

I have a list Joomla! form field in my XML, it works in the back end, I can change the dropdown. When saved, the item stays the same.

When I print_r($params)

The value is outputted as "true" and not the value sometimes it appears as 1, no matter which option I choose.

If I change the PHP I obtain a

What could cause this given the option is selected correctly when I view it in the back end.

XML

        <field name="list"
               type="list"
               default=""
               label="MOD_KOY_YOUR_LOGO_LIST"
               description="">
            <option value="0">MOD_MY_MOD_OPTION_LOGO_ONLY</option>
            <option value="1">MOD_MY_MOD_OPTION_TEXT_ONLY</option>
            <option value="2">MOD_MY_MOD_OPTION_TEXT_AND_LOGO</option>
        </field>

Could it be possible that my use of multiple showon= are causing the issue? all seem to work correctly, but some are nested. By nested I mean if a = 1, then show b. If b = 1 then show c.

1 Answer 1

1

I worked out that I needed to ensure my output was a number as opposed to true/false or 0/1 etc (boolean).

The way I did this was to set it as intval

$list= intval($params['list']);

Then I can call $list in my if statement and it will perform correctly.

Hope this helps someone else in the future if there's a better way please comment.

2
  • Please could you mark the answer as "accepted" so others know it has been solved? Thanks
    – Lodder
    Commented Jun 18, 2018 at 12:50
  • Cheers for the reminder. It made me wait. Have done so now
    – Eoin
    Commented Jun 18, 2018 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.