Optionally you can pass in a prefix for form variables to allow for potential naming problems for properties of multiple objects.
Ideally you pass in existing object and Web Connection will populate the properties of the object from the form variables.
If you don't pass an object a generic object is created for you with properties for each of the form variables of the HTML form and populated with String values (requires VFP8 or later).
This method can be extremely useful for reducing form variable retrieval code from your Web applications especially if you map form fields directly to objects. Form variables must match the property names either directly or with an optional prefix (such as txt, but the prefix must consistent for all variables).
o.FormVarsToObject(loObject,lcPrefix)
lcPrefix
An optional prefix that can be used in form variables. This prefix is stripped when matching property values.
Object and array members are ignored and not filled or updated. Date values are imported with CTOD and CTOT. There may be formatting problems so these properties may require post processing and potential problems with SET STRICTDATE settings.
You can work around any misparsing problems by performing additional post processing on the captured object data or handling any fields that might have been missed manually.
This method may cause problems when capturing logical values into object proeprties that are not part of the form displayed. This comes from the HTML limitation of checkboxes and radios not returning an unchecked value. The method assumes that any logical value not found in the request data is false. This can cause any properties not on the form to be forced to a value of .F. even though the original value was .T. The workaround is to capture any non-participating logical value to tempoary vars and then restore them after the method call is completed.
*** Using a cursor USE wws_Customer SCATTER NAME loCustomer MEMO BLANK Request.FormVarsToObject(loCustomer)
*** Using a 'real' business object loCust = CREATE("cCustomer") loCust.New() *** Store form vars to oData properties Request.FormVarsToObject(loCust.oData) IF !loCust.Validate() THIS.Errormsg("Invalid Data") RETURN ENDIF loCust.Save()
*** Without an object passed in loFormVars = Request.FormVarsToObject() *** Retrieve the txtName and txtCompany variables lcName = loFormVars.txtName lcCompany = loFormVars.txtCompany