XF 2.0 Form disabler and field-adder don't work together?

Jaxel

Well-known member
I am trying to use the field-adder function, in conjunction with a disabler. On first appears, it works... however, new fields added by the field-adder function come in disabled, even if it's supposed to be enabled.

HTML:
<xf:checkboxrow>
    <xf:option name="custom_excerpt" value="1"
        checked="{{ $earnings ? true : false }}"
        data-xf-init="disabler"
        data-container="#Earnings"
        data-hide="false" />
</xf:checkboxrow>

<xf:formrow rowtype="input" id="Earnings">
    <ul class="listPlain inputGroup-container">
        <xf:foreach loop="$earnings" key="$counter" value="$earning">
            <li class="inputGroup">
                <xf:textbox name="earnings[{$counter}]" value="{$earning}" />
            </li>
        </xf:foreach>

        <li class="inputGroup" data-xf-init="field-adder" data-increment-format="earnings[{counter}]">
            <xf:textbox name="earnings[{{ count($earnings) }}]" />
        </li>
    </ul>
</xf:formrow>
 
When the field adder object is initialized, the field is cloned and cached to an object property. You'd need to write a custom JS extension to get it to play nicely with the disabler.
 
I figured it out:

JavaScript:
    XF.Element.extend('field-adder',
    {
        __backup:
        {
            'init': '_init',
            'create': '_create',
        },
        
        init: function()
        {
            this._init();
        },
        
        create: function()
        {
            this._create();
        },
    });
 
It looks like this issue was fixed in XF2.3 and a extension is no longer needed to manually fix it.
 
Back
Top Bottom