...
Ok, let's get more specific. Put the following code in any formtool you extend. Such as a simple extend of a This is a sample edit() function for a formtool such as 'string'. (farcry.core.packages.formtools.string). Put it in the function edit() right after the <cfset var html="">. Delete everything else in the function except <cfreturn html>Note that the only difference between this and a function such as display() is the use of super.edit() vs. super.display().
Code Block | ||
---|---|---|
| ||
<cffunction name="edit" access="public" output="true" returntype="string" hint="his will return a string of formatted HTML text to enable the user to edit the data"> <cfargument name="typename" required="true" type="string" hint="The name of the type that this field is part of."> <cfargument name="stObject" required="true" type="struct" hint="The object of the record that this field is part of."> <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."> <cfargument name="fieldname" required="true" type="string" hint="This is the name that will be used for the form field. It includes the prefix that will be used by ft:processform."> <cfset var html = "" /> <cfset var jsscript = "" /> <cfif structkeyexists(arguments.stMetadata,"ftWatch") and len(arguments.stMetadata.ftWatch) AND structkeyexists(arguments.stObject,"#listfirst(arguments.stMetadata.ftWatch)#") AND ( ( isValid("boolean",arguments.stObject[listfirst(arguments.stMetadata.ftWatch)]) AND NOT arguments.stObject[listfirst(arguments.stMetadata.ftWatch)] ) OR NOT len( arguments.stObject[listfirst(arguments.stMetadata.ftWatch)] ) ) > <cfsavecontent variable="jsscript"><cfoutput> <script type='text/javascript'> var el = Ext.get('#arguments.fieldname#ajaxdiv') if (null != el) { if (el.parent("div").parent("div").is('div.fieldSection') ) { el.parent("div").parent("div").setStyle('display','none'); } } </script> </cfoutput></cfsavecontent> <cfset html = jsscript /> <cfelse> <cfsavecontent variable="jsscript"><cfoutput> <script type='text/javascript'> var el = Ext.get('#arguments.fieldname#ajaxdiv') if (null != el) { if (el.parent("div").parent("div").is('div.fieldSection') ) { el.parent("div").parent("div").setStyle('display','block'); } } </script> </cfoutput></cfsavecontent> <cfset html = jsscript & super.edit(argumentCollection="#arguments#") /> </cfif> <cfreturn html> </cffunction> |
The <cfif> structure is simply there to check that all the proper metadata exists and that it is of the proper type. Then to actually check the value, you call
...