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

XF 1.3 Radio Buttons Custom Fields Code

Discussion in 'Styling and Customization Questions' started by Michael, Nov 27, 2014.

  1. Michael

    Michael Active Member

    Hey everyone,

    I am wanting to use radio button custom fields to change some text depending on member selection for example:

    Bob can choose between cars and nothing else, if he chooses cars I want cars to display in the message template, if he chooses nothing else I want a default text to display instead.

    Does anyone know how to get this to work with radio buttons?

    I have done some searching but the code I have found doesnt appear to work.

    Thank you.

    @Jake Bunce do you have any idea on this one? :D Thanks
    Last edited: Nov 27, 2014
  2. Michael

    Michael Active Member

    Any ideas anyone?
  3. Brogan

    Brogan XenForo Moderator Staff Member

    I'm not entirely sure what it is you are trying to do, but you will just need to edit the template in which you want the text to appear and use a conditional statement (xen:if) for the custom user field.
    Michael likes this.
  4. Michael

    Michael Active Member

    Im wanting to use else ifs for a radio button custom user field within the message template but I am unsure what code to use to get the radio buttons to work correctly. I have tried with a few snippets I have found here but none seem to work for me.

    This is the code I am using:

    <xen:if is="{$message.customFields.my_fieldid.on} == 'on'">Blue<xen:else />Pink</xen:if>
    When either option is selected under personal details it doesnt seem to have any effect on the output and only Pink is showing regardless of the option chosen.

    Hope that makes it clearer what I am trying to do here :)
  5. Brogan

    Brogan XenForo Moderator Staff Member

    If there are only two choices (cars and nothing else), why not just make it a checkbox?
    Michael likes this.
  6. Michael

    Michael Active Member

    I could but I dont know the code for that either :D
  7. Brogan

    Brogan XenForo Moderator Staff Member

    An example:
    <xen:if is="{$visitor.customFields.FieldName}">
        Text to display if the field is checked
    <xen:else />
        Text to display if the field is not checked
    Michael likes this.
  8. Michael

    Michael Active Member

    Thank you Brogan I will give that a try. Do you know the code if I wanted to add multiple options to the checkboxes?

Share This Page