No announcement yet.

Displaying field label instead of value

  • Filter
  • Time
  • Show
Clear All
new posts

  • Displaying field label instead of value


    I'm trying to reference a radio button field for an e-mail. I'd like to utilize the label looked up instead of the value. For instance if I have a radio button with the values "Yes" (1) "No" (0), the value that goes in the database is the 1 or 0. However, i would like to display the label "Yes" or "No" in this e-mail. Is there an easier way to this than using sc_lookup to find the "Label" value?

  • #2

    you will have to analize the code generated by SC and find the correct value... SC creates a series of variables for every label such as


    Where login is the name of the field, then all you have to do is to correlate the value to the label.



    • #3
      I found it in the code, but I get this error when I try to print it:

      Undefined index: pickupsitetype

      I'm kind of astounded Scriptcase doesn't have an easy way to reference this information. I used a manual look up declaration for the field and set the label/value pairs. Is there really no easy way to reference the label instead of the value?


      • #4
        Remember that if you have a roundbutton or checkbox those are arrays.

        Verify the array depending on the value.



        • #5
          I haven't had any luck. Every time I try to reference the variables associated with the field, they are empty. I found the portion of the code that determines the output based on user selection.

          if ("1" == $this->pickupsitetype) { $pickupsitetype_look = "Commercial";}

          However, whenever I try to use $pickupsitetype_look in my event code, the variable is empty. I'd like to be able to easily reference the variable that contains "Commercial", because that is the actual information I need to use. I know there are ways around this, but it would make things a lot easier to be able to access this information directly.


          • #6
            ok catalyst:

            I think you are overthinking this... the checkbox or radio button field comes from a query or from a manually defined list... regarding the case you know the relation value to label..

            if it comes from an SQL query simply execute the query where the id = the value you gather from the field. and use the result of such query, if it comes from a manually defined list use a switch/case sentence to analyze the value of the field and use it.



            • #7
              I appreciate your help kafecadm, but my whole objective was to streamline this and make it easier. Since I already defined a manual list under the fields "lookup settings", I was hoping to have access to the "label" portion on the fly without having to worry about writing a switch case for every single field (and there are MANY). I can do this if it's absolutely required, but I felt like there had to be a more efficient way to do this that I simply didn't know about.

              It seems logical to have access to the label variable in an easy way without having to write a switch structure for every single field. Like in an array, as you suggested for example: $label_name['$this->pickupsitetype'] or $label_name[{PickupSiteType}].

              From what I can tell, what I am trying to accomplish simply isn't possible. It appears there is no way to access the "label" portion in the "lookup settings" in an event, only the "value."

              Thanks for trying to help kafecadm. I always feel like I'm fighting with Scriptcase to get things done. It certainly makes a lot of things easier, but in other ways it is very constrictive and non-intuitive.


              • #8
                ok, ill try to take a deep look into the code later tonight. maybe i can help youl.