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

Disabling Option

Discussion in 'XenForo Development Discussions' started by ragtek, Feb 16, 2011.

  1. ragtek

    ragtek Guest

    Is there already any way, to make a option depending(disabled/enabled) from an other option?

    For example:
    inviteoptiondisa.PNG
    Expiretime should only be enabled, if the "delete invites" checkbox is activated.


    I know that the js is already coded
    Code:
    	/**
    	 * Allows an input:checkbox or input:radio to disable subsidiary controls
    	 * based on its own state
    	 *
    	 * @param {Object} $input
    	 */
    	XenForo.Disabler = function($input)
    but can i use this without own templates for the options?
     
  2. SchmitzIT

    SchmitzIT Well-Known Member

    I asked the same question, but have yet to get a confirmation on how to do it... I'd also like to know :)
     
  3. Shadab

    Shadab Well-Known Member

    I think you'll have to create a "template" driven option. And in your template, create a nested xen:option tag. I believe the inner options would then depend on the outer option to be enabled or "checked" for it to work.
     
  4. ragtek

    ragtek Guest

    hm, didn't understand that:D
    so i had to implement a own template with some jquery code to hide/show the elemets.

    It's extremly ugly for example: $elem.parent().parent().hide() but it's working^^
     
  5. Tilkißey

    Tilkißey Well-Known Member

    example from admin.php?options/list/twitter
    this page is using "named template" format and its template's name is "option_template_tweet"
    HTML:
    <xen:checkboxunit label="" hint="{$preparedOption.hint}">
    <xen:option name="{$fieldPrefix}[{$preparedOption.option_id}][enabled]" selected="{$preparedOption.option_value.enabled}">
    <xen:label>{$preparedOption.title}</xen:label>
    <xen:textbox name="{$fieldPrefix}[{$preparedOption.option_id}][via]" value="{$preparedOption.option_value.via}" placeholder="{xen:phrase via_twitter_account}" />
    <xen:textbox name="{$fieldPrefix}[{$preparedOption.option_id}][related]" value="{$preparedOption.option_value.related}" placeholder="{xen:phrase related_twitter_account}" />
    </xen:option>
    <xen:explain>{xen:raw $preparedOption.explain}</xen:explain>
    <xen:html>
    <input type="hidden" name="{$listedFieldName}" value="{$preparedOption.option_id}" />
    {xen:raw $editLink}
    </xen:html>
    </xen:checkboxunit>
     
  6. ragtek

    ragtek Guest

    thx, but i've made it now an other way
    IMHO the users shouldn't see anything, what's not usable^^
    video: http://ragtek.org/videos/nuns.htm

    (very handy that ajnos uploaded this some minutes ago:D for an other thread:D http://xenforo.com/community/threads/ragtek-new-user-mail.8701/page-2#post-195823)
     
  7. xfrocks

    xfrocks Well-Known Member

    Ah ha, another related thread for http://xenforo.com/community/threads/js-challenge.15170/

    You can do this

    Code:
    <xen:checkboxunit label="">
    <xen:option name="name" value="value" inputclass="Disabler" id="checkbox_id_123" />
    </xen:checkboxunit>
    
    <div id="check_box_id_123_Disabler">
    your other stuff goes here
    </div>
    
    You can choose to hide it or disable it only. Simply add one more class: "Hider"

    PS: If this code doesn't work, you probably need to play around with the id. I'm not at my dev machine atm to test :p But it works, I swear!
     
  8. ragtek

    ragtek Guest

    With this i would need own templates for every option or?

    ATM i've just created the "normal" options in the debugmode....

    The problem is, that i've tried to add inputclass="Disabler" in the Format Parameters field, BUT it's not possible for checkboxes:(

    Code:
    <template title="option_list_option_onoff"><![CDATA[<xen:checkboxunit hint="{$preparedOption.hint}">
        <xen:label>{$_preparedOption.title}</xen:label>
        <xen:option name="{$fieldPrefix}[{$preparedOption.option_id}]" selected="{$preparedOption.option_value}">
            <xen:label>{$preparedOption.title}</xen:label>
            <xen:hint>{xen:raw $preparedOption.explain}</xen:hint>
        </xen:option>
        <xen:html>
            <input type="hidden" name="{$listedFieldName}" value="{$preparedOption.option_id}" />
            {xen:raw $editLink}
        </xen:html>
    </xen:checkboxunit>]]></template>
    There's no place for the class^^
     

Share This Page