Note: After I wrote this article, Laura Arguello offered some valuable feedback which led me to a similar but better solution.Since I learned something new, I wanted to pass it along, so this article is now superseded by (a better way to) dynamically change a cfinput field’s label.
We need to have a form field whose content will control the label of our text input field.
Since we probably don’t want to have some random control appearing in the form, our best option is to use a hidden form field ().
This Cold Fusion code gets turned into the following MXML: tag is the “bind” attribute, which allows us to specify an object property that will serve as the source of the text.
So we’ll get the text into the label dynamically using a bind statement; the only question is, what do we specify as object/property to “bind” our label to?
So that I don’t have to keep repeating it in later code listings, this is the CF code for the combo box and the form.
Notice that to keep this example simple I’ve just put the desired label in as the value in each I think much of the confusion about being able to change a cfinput text field’s label dynamically lies in the way you define the label on a cfinput text field (by setting the “label” attribute in the tag – very easy).
Once the Cold Fusion code gets turned into Flex MXML, the Cold Fusion code is gone and you need to use the Flex object model to access the properties of your form fields (more on this subject).
One of the places this gives us trouble is with the label of a cfinput field such as an ordinary text input field.
To demonstrate this idea, I’ve built a simple CF Flash Form that has a combo box ().