• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 Problem with array option saving

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


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:

Change option value > Save > CTRL+F5.
 

Chris D

XenForo developer
Staff member
#2
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>
 
#3
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:
 

Chris D

XenForo developer
Staff member
#4
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).