XF 2.0 Problem with array option saving

AlessioDP

Member
I have a problem on saving an "On/off checkbox with textbox".
1d369a63f7.png


When I try to CTRL+F5 after saving a value inside the option everything got disabled but on the database I can see the changes. Is it a bug?

This is an example gif:
bd0af83719.gif

Change option value > Save > CTRL+F5.
 
On / off checkbox with text box types are a little easier to set up than that.

For example, check the existing XF option approveSharedBannedRejectedIp.

The main thing of note there would be the format parameters:
Code:
onoff=enabled
value=days
onoff makes the name of the checkbox as enabled and value makes the name of the text field as days.

Then your array sub options (and your default value) would just be enabled and days so that you will access the option like this:
Code:
<xf:if is="$xf.options.yourOptionId.enabled">
    {$xf.options.yourOptionId.days}
</xf:if>
 
On / off checkbox with text box types are a little easier to set up than that.

For example, check the existing XF option approveSharedBannedRejectedIp.

The main thing of note there would be the format parameters:
Code:
onoff=enabled
value=days
onoff makes the name of the checkbox as enabled and value makes the name of the text field as days.

Then your array sub options (and your default value) would just be enabled and days so that you will access the option like this:
Code:
<xf:if is="$xf.options.yourOptionId.enabled">
    {$xf.options.yourOptionId.days}
</xf:if>
Thank you :)

Just another question:
When you uncheck an option then save, the value inside the textbox is set to empty, can be disabled that? I just want save the value even if the checkbox is unchecked:
63be1aa7a8.png
 
Unfortunately not, that's just how the values are sent to the server -- values in disabled fields are essentially ignored (by the web server itself, so out of our control).
 
@Chris D

Quick question. How could I make it so an option checkbox is unchecked after saving? For example a user would check a checkbox and then save and it would be unchecked. Trying to add a reset count option in my MostEverOnline add-on

Just for the record I'm not using the same type of checkbox as this guy. Just an ordinary checkbox
 
You would likely want to use a validation callback.

That would detect the value of the checkbox and take action if it is checked, and if it is, actually set the value back to a falsey value so it remains unchecked.
 
Back
Top Bottom