ePages 7.21.0 - DE_EPAGES/TLE/API/FormHandler.pm

Package DE_EPAGES::TLE::API::FormHandler

This package provides functions to switch the form error handling on/off. §note This file was renamed from ./FormErrorHandler.pm

Functions

ERROR_VALUE
FORMERROR_DETAILS
FORM_ARRAY
FORM_ERROR
WITH_ERROR

ERROR_VALUE

This tle function allows to set a tle depending on FormError status.

Syntax
#ERROR_VALUE(#ValueIfError, #ValueIfNoError)
Example
#WITH_ERROR(#FormError)
 <input name="Alias" value="#Alias">
  #LOCAL("RefUnitID", #ERROR_VALUE(#RefUnit, #RefUnit.ID))
 <select name="RefUnit" size="1">
   <option value="">{EmptyEntry}</option>#LOOP(#Shop.Units)
   <option value="#ID"#IF(#RefUnitID AND #RefUnitID NEQ #ID) selected="1"#ENDIF>#IF(#Name)#Name#ELSE#Alias#ENDIF</option>#ENDLOOP
 </select>
  #ENDLOCAL
#ENDWITH_ERROR
Input
#ValueIfError (string)
value in case of an error
#ValueIfNoErro (string)
value in case of no error

FORMERROR_DETAILS

Returns the error hash of a single input or of the current item of a loop.

Syntax
#FORMERROR_DETAILS(#InputName)
Example
#FORMERROR_DETAILS("OrderConfirmationText")
#LOCAL("ErrorItemNo", 1)
  #LOCAL("Error", #FORMERROR_DETAILS("OrderConfirmationText"))
    #IF(#DEFINED(#Error) AND #LoopError.Reason EQ "TLE_ERROR")
      <h3>{InputError} - TLE_ERROR</h3>
      {TLESyntaxError}
    #ENDIF
  #ENDLOCAL
#ENDLOCAL
Input
#InputName (string)
input name
Return
#Error (ref.hash)
form error hash - keys:
  • MaxValue - int
  • LoopName- loop name - string
  • Reason - error reason - string
  • Error - blessed error object
  • Type - input value type - string
  • FieldID - input field id - integer
  • Message - error message - string
  • Vars - error vars - hash.ref
  • Form - form name - string
  • ErrorPackage - 'DE_EPAGES::TLE::API::Parser'
  • Index - 0
  • MinValue - int
  • FormID - form id - integer
  • Line - line number - integer
  • Mandatory - input field is mandatory - boolean
  • yyparse - yyparse output - string
  • LoopID - loop id - integer
  • Name - input name - string

    FORM_ARRAY

    Treats a string from the INPUT Hash as an array representation and returns an array reference of hashes. Each array element is a hash containing an element with the key "Element", that references the original array element value.

    Syntax
    #FORM_ARRAY(#InputName)
    Example
    #FORM_ARRAY("Elements")
    #LOOP(#FORM_ARRAY("Elements"))#Element#ENDLOOP
    Input
    #InputName (string)
    input name

    FORM_ERROR

    This tle function allows to get FormError_InputName with a variable input name.

    Syntax
    #FORM_ERROR(#FieldName)
    #FORM_ERROR(#FieldName)
    Example
    <input name="Alias"#IF(#FORM_ERROR("Alias")) style="color:red"#ENDIF value="#Alias">
    Input
    #FieldName (string)
    input field name

    WITH_ERROR

    This function applies the automatic replacement of tles with the form error value. The tles will only be replaced at the current context. Important for the replacement is that the tle has the same name as the input field.

    Syntax
    #BLOCK("WITH_ERROR", #ReplaceOrNot) ... template ... #ENDBLOCK
    #WITH_ERROR(#ReplaceOrNot) ... template ... #ENDWITH_ERROR
    Example
    #WITH_ERROR(#FormError)<input name="Alias" value="#Alias">#ENDWITH_ERROR
    Input
    $Processor (object)
    tle processor
    $raParams (ref.array.string)
    tle function parameter
    $cTemplate (ref.*)
    template code for replaceTLEs
    Return
    $Value (string)
    template string