1

In a plugin config xml file, the following creates a config checkbox fine:

<field name="post_allowed" type="checkbox"
  default="0"
  description="Post Allowed"
  label="Post Allowed"
/>

However if I change the default to 1, it breaks to config screen. It becomes impossible to uncheck the it:

<field name="post_allowed" type="checkbox"
  default="1"
  description="Post Allowed"
  label="Post Allowed"
/>
  • I've just tested your exact code and it works fine for me. What version of Joomla are you using? And are you using the latest version of your build? – Lodder Mar 25 '15 at 10:26
  • Joomla! 3.3.6 pretty recent. Unchecking, saving, refreshing leaves to box checked – MadMaardigan Mar 25 '15 at 13:13
1

The issue here is that deselecting post_allowed and then submitting the form will not submit any value for post_allowed.

So if you had the plugin's post_allowed value stored as 1 in the database, then you edit the plugin options page, deselect the checkbox and press save, no data is sent for post_allowed and thus the original value of 1 is not replaced.

I would suggest replacing the checkbox with a radio button:

<field name="post_allowed" type="radio"
  class="btn-group"
  default="1"
  description="Post Allowed"
  label="Post Allowed">
    <option value="0">JNO</option>
    <option value="1">JYES</option>
</field>

Your Answer

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

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