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

Fixed Poll "Add additional response" button bug

Discussion in 'Resolved Bug Reports' started by RichardKYA, Jul 29, 2016.

  1. RichardKYA

    RichardKYA Well-Known Member

    If you are 1 response away from the total maxResponses when you go to edit a poll, the additional field shows as expected, but the "add additional response" button also stills shows even though you can not add any further responses, so you are left with a 'dead' button.

    To replicate:

    1: Set "Maximum Number of Poll Choices" to "3" (it can be any number, this is just to make things easier for testing)
    2: Create a poll with only 2 responses
    3: Edit the poll and you'll see the field for your 3rd (and final) response and also the button (which does nothing when clicked)

    I found that doing this in 'thread_poll_edit' fixes the issue:

    Find:
    Code:
    <input type="button" value="{xen:phrase add_additional_response}" class="FieldAdder button smallButton" data-source="ul.PollResponseContainer li" data-maxfields="{$xenOptions.pollMaximumResponses}" />
    
    Replace:
    Code:
           <xen:if is="{xen:count $poll.responses} < {xen:calc '{$xenOptions.pollMaximumResponses} - 1'}">
           <input type="button" value="{xen:phrase add_additional_response}" class="FieldAdder button smallButton" data-source="ul.PollResponseContainer li" data-maxfields="{$xenOptions.pollMaximumResponses}" />
           </xen:if>
    
    Anyway, I'll leave it with you guys to do as you please, thanks for reading :)
     
  2. Mike

    Mike XenForo Developer Staff Member

    There are some fairly complex permutations here to handle this generically, as there's the case where the poll doesn't exist, where it does exist (normal) and where it's a draft. As such, I've handled this in JS. It will hide the button as needed and, if for some reason it's still there when it's not needed, a click will remove it.
     
    RichardKYA likes this.

Share This Page