1

I have a simple form that is suppose to show one field.

Controller:

public function t_validate_3()
        {
            title = "Complete";

            supervisor = model("supervisors").new();


        }

View 1: Using Form helpers (work)

<cfoutput>

#startFormTag(action="t_validate")#

    <div>
        #textField(label="Supervisor Name:", objectName="supervisor", property="name")#
        #errorMessageOn(objectName="supervisor", property="name")#
    </div>

    #submitTag()#

#endFormTag()#

</cfoutput>

View 2: Using Plain old HTML (doesn't work)

<cfoutput>


    #startFormTag(action="t_validate_3")#

        <div>
            <label for="Name">Supervisor: </label>
            <input id="Name" name="supervisor[name]" value="#supervisor.name#" />
            #errorMessageOn(objectName="supervisor", property="name")#
        </div>

        #submitTag()#
    #endFormTag()#

</cfoutput>

The error above is "Element NAME is undefined in SUPERVISOR." This error comes from the line "#supervisor.name#". Keep in mind, I know initially it is empty but I need that line so it remembers the value if it is filled. I got the idea from the documentation;

http://docs.cfwheels.org/docs/form-helpers-and-showing-errors

However it doesn't seem to work. Is there a way for the form to ignore if it empty but remember if it is filled without this error.

Please help.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Saad A
  • 1,135
  • 2
  • 21
  • 46
  • Why are you not using the form helper? – Chris Peters Nov 23 '15 at 14:59
  • Because I am using bootstrap 3 styles. It is just easer I feel to construct the form that way. because it was getting really complicated using the form_helper wrappers – Saad A Nov 23 '15 at 18:42
  • You may want to look at the code in the bootstrap-cfwheels plugin that we started a number of years ago. https://github.com/liquifusion/bootstrap-cfwheels It may not do exactly what you want, but it could show you how you could create your own helpers. – Chris Peters Nov 23 '15 at 19:19
  • 1
    Otherwise, you'll need to probably use `` extensively at the top of your views to set default values for the form fields. For example: `` – Chris Peters Nov 23 '15 at 19:20

0 Answers0