저는 바퀴가 새롭기 때문에 (그리고 저는 여기에 많이 올릴 것이라고 확신합니다.CFWheels - 동일한 모델을 사용하여 두 개의 다른 형식을 확인하십시오.
"user"컨트롤러 아래에 "register"와 "login"의 두 가지 형식이 있습니다. 그래서 내 URL의 모습입니다. 이 잘 작동 -
/사용자/나는 단순히 init 메소드 내부의 "등록"페이지에 대한 검증과 user.cfc이 내 모델 폴더에 순간/ /사용자/로그인/
를 등록합니다.
본질적으로 ... 제 질문은 ... 로그인 양식의 유효성 확인과 관련되어 있습니다. 항상 init 메소드 또는 다른 메소드에 유효성을 배치해야합니까? 그렇다면 어떻게해야합니까? 각 형태의 코스는 서로 다른 필드를 가지고 있습니다 ... 그래서 어떤 형태가 현재 플레이되고 있는지를 감지 할 때 어떤 논리를 알아야합니다.
희망적입니다. 참고로, 내 user.cfc 모델은 현재 다음과 같습니다
<cfcomponent extends="Model" output="true">
<cffunction name="init">
<cfset validate(property='userName', method='validateAlphaNumeric') />
<cfset validatesPresenceOf(properties='userName') />
<cfset validatesUniquenessOf(properties='userName') />
<cfset validatesFormatOf(property='userEmail', type='email', message="Email address is not in a valid format.") />
<cfset validatesPresenceOf(properties='userEmail') />
<cfset validatesUniquenessOf(properties='userEmail') />
<cfset validatesPresenceOf(properties='userPassword') />
<cfset validatesConfirmationOf(property='userPassword') />
<cfset validatesLengthOf(property="userToken", allowBlank=true) />
</cffunction>
<cffunction name="validateAlphaNumeric" access="private">
<cfif REFind("[^A-Za-z0-9]", this.userName, 1)>
<cfset addError(property="userName", message="User name can only contain letters and numbers.") />
</cfif>
</cffunction>
</cfcomponent>
감사합니다, 마이클.
첫 번째 검증 규칙에서는'property = 'userName''이 필요하지 않습니다. 필요한 것은'method' 인수뿐입니다. –