Does anyone have an idea how exactly ftValidate*PropertyName* method work?

I'm just wondering did I miss any steps to get the validation error
displayed within the webtop or is this a bug in FarCry?

Any thoughts would be much appreciated.



On Tue, Aug 20, 2013 at 3:02 PM, Xiaofeng Liu <[email protected]>wrote:

> Hi Chris,
>
> Thanks for pointing to the use of form tools validation methods. However,
> how would I get the error message displayed on my custom type edit form?
>
> I have the property set to:
>
> <cfproperty ftseq="50" ftFieldSet="Login" type="string" ftLabel="Username"
> name="username" ftType="string" ftValidation="required" bLabel="true">
>
> Then I have my validation method as:
>
> <cffunction name="ftValidateUsername" access="public" output="true"
> returntype="struct" hint="This will return a struct with bSuccess and
> stError">
>  <cfargument name="objectid" required="true" type="string" hint="The
> objectid of the object that this field is part of.">
>  <cfargument name="typename" required="true" type="string" hint="The name
> of the type that this field is part of.">
>  <cfargument name="stFieldPost" required="true" type="struct" hint="The
> fields that are relevent to this field type.">
>  <cfargument name="stMetadata" required="true" type="struct" hint="This
> is the metadata that is either setup as part of the type.cfc or overridden
> when calling ft:object by using the stMetadata argument.">
>   <cfset var stResult = structNew()>
>  <cfset var qDuplicate = queryNew("blah")>
> <cfset stResult = createObject("component",
> application.formtools["field"].packagePath).passed(value=stFieldPost.Value)
> />
>  <!--- --------------------------- --->
>  <!--- Perform any validation here --->
> <!--- --------------------------- --->
>  <cfquery datasource="#application.dsn#" name="qDuplicate">
> SELECT objectid from userProfile
>  WHERE upper(username) = '#ucase(stFieldPost.Value)#'
> </cfquery>
>   <cfif qDuplicate.RecordCount>
>  <!--- DUPLICATE USERNAME --->
> <cfset stResult = createObject("component",
> application.formtools["field"].packagePath).failed(value="#arguments.stFieldPost.value#",
> message="The username you have selected is already taken.") />
>  <!--- <cfdump var="#stResult#"><cfabort> --->
> </cfif>
>  <!--- ----------------- --->
> <!--- Return the Result --->
>  <!--- ----------------- --->
> <cfreturn stResult>
>  </cffunction>
>
> If I dump out the stResult, I can see ftValidateUsername is invoked and it
> correctly detected the duplicates and set the error message:
>
> struct BSUCCESS false  STERROR  struct CLASS validation-advice  MESSAGE The
> username you have selected is already taken.    VALUE flyingturtle123
>
> However, without abort execution, it still saved the record and not
> displaying the validation message anywhere.
>
> Am I missing sth here?
>
>
>
>
> On Mon, Aug 19, 2013 at 6:42 PM, Chris Kent <[email protected]> wrote:
>
>> You would probably be better off using a validate method inside your
>> content type. you can set these to validate individual properties. Default
>> is to name the function "ftValidate+propertyname", e.g. ftValidateUserID
>>
>> Look at ftValidateUserID in /core/packages/types/farUser.cfc for an
>> example to check for unique userID.
>>
>> Chris
>>
>>
>> On Monday, 19 August 2013 09:02:46 UTC+1, Xiaofeng Liu wrote:
>>>
>>> Hi,
>>>
>>> Within webtop on a custom type, if I'd like to use beforeSave() to
>>> check, for example the uniqueness of username before my type record gets
>>> saved, how do I bring back that validation message to display on the farcry
>>> scaffolded list view or maybe the add/edit view?
>>>
>>> --
>>> Best regards,
>>>
>>> Xiaofeng
>>>
>>  --
>> You received this message cos you are subscribed to "farcry-dev" Google
>> group.
>> To post, email: [email protected]
>> To unsubscribe, email: [email protected]
>> For more options: http://groups.google.com/group/farcry-dev
>> --------------------------------
>> Follow us on Twitter: http://twitter.com/farcry
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "farcry-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Best regards,
>
> Xiaofeng,^_^
>



-- 
Best regards,

Xiaofeng,^_^

-- 
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: [email protected]
To unsubscribe, email: [email protected]
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry
--- 
You received this message because you are subscribed to the Google Groups 
"farcry-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to