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:
    Expiretime should only be enabled, if the "delete invites" checkbox is activated.

    I know that the js is already coded
    	 * 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"
    <xen:checkboxunit label="" hint="{$preparedOption.hint}">
    <xen:option name="{$fieldPrefix}[{$preparedOption.option_id}][enabled]" selected="{$preparedOption.option_value.enabled}">
    <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:explain>{xen:raw $preparedOption.explain}</xen:explain>
    <input type="hidden" name="{$listedFieldName}" value="{$preparedOption.option_id}" />
    {xen:raw $editLink}
  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

    <xen:checkboxunit label="">
    <xen:option name="name" value="value" inputclass="Disabler" id="checkbox_id_123" />
    <div id="check_box_id_123_Disabler">
    your other stuff goes here
    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:(

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

    Beanjam Active Member

    How can I implement only the Hider?

    I want to hide a select element, but retain its value in the database. The Disabler class deletes the value.

    Alternatively, does anyone have a suggestion for how to select the first item in the select element automatically upon ticking the checkbox?

    The problem I have is that users will tick the checkbox, enabling the select but then not choose an item from the list. I could set a default upon submission of the form, or display a required field error message, but prefer that it is dealt with before submission.
  10. Beanjam

    Beanjam Active Member

    Bumping this, anyone know if it's possible to only implement the Hider class?

Share This Page