Search code examples
coldfusioncoldfusion-8cfml

ColdFusion: Best way to use HTMLEditFormat for all form input fields


I have form uses HTMLEditFormat call for every single input fields. is there any way so I can call HTMLEditFormat function only once and it will take care of all input fields instead of adding it to every single field?


Solution

  • The following will accomplish your goal, but like has been pointed out in the comments section, this may not be your best option.

    <cfset cleanForm = {}>
    <cfloop list="#form.fieldnames#" index="i">
      <cfset cleanForm[i] = HTMLEditFormat(form[i])>
    </cfloop>
    

    Instead of referencing form.firstName you would now reference cleanForm.firstName