PHP 클래스 Contao\Widget

The class functions as abstract parent class for all widget classes and provides methods to generate the form field markup and to validate the form field input. Usage: $widget = new TextField(); $widget->name = 'test'; $widget->label = 'Test'; if ($_POST) { $widget->validate(); if (!$widget->hasErrors()) { echo $widget->value; } }
상속: extends contao\BaseTemplate
파일 보기 프로젝트 열기: contao/core-bundle 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$arrAttributes array Attributes
$arrConfiguration array Configuration
$arrErrors array Errors
$arrOptions array Options
$blnForAttribute boolean For attribute indicator
$blnSubmitInput boolean Submit indicator
$objDca object Data container
$strClass string CSS class
$strId integer Id
$strLabel string Label
$strName string Name
$strPrefix string CSS class prefix
$strWizard string Wizard
$varValue mixed Value

공개 메소드들

메소드 설명
__construct ( array $arrAttributes = null ) Initialize the object
__get ( string $strKey ) : string Return an object property
__isset ( string $strKey ) : boolean Check whether an object property exists
__set ( string $strKey, mixed $varValue ) Set an object property
addAttribute ( string $strName, mixed $varValue ) Add an attribute
addAttributes ( array $arrAttributes ) Take an associative array and add it to the object's attributes
addError ( string $strError ) Add an error message
generate ( ) : string Generate the widget and return it as string
generateLabel ( ) : string Generate the label and return it as string
generateWithError ( boolean $blnSwitchOrder = false ) : string Generate the widget with error message and return it as string
getAttribute ( string $strKey ) : string Return a single attribute
getAttributes ( array $arrStrip = [] ) : string Return all attributes as string
getAttributesFromDca ( array $arrData, string $strName, mixed $varValue = null, string $strField = '', string $strTable = '', DataContainer | null $objDca = null ) : array Extract the Widget attributes from a Data Container array
getEmptyStringOrNull ( ) : string | integer | null Return either an empty string or null based on the SQL string
getEmptyStringOrNullByFieldType ( string $sql ) : string | null Return either an empty string or null based on the SQL string
getEmptyValue ( ) : string | integer | null Return the empty value based on the SQL string
getEmptyValueByFieldType ( string $sql ) : string | integer | null Return the empty value based on the SQL string
getErrorAsHTML ( integer $intIndex ) : string Return a particular error as HTML string
getErrorAsString ( integer $intIndex ) : string Return a particular error as string
getErrors ( ) : array Return the errors array
getErrorsAsString ( string $strSeparator = null ) : string Return all errors as string separated by a given separator
hasErrors ( ) : boolean Return true if the widget has errors
optionChecked ( string $strOption, mixed $varValues ) : string Return a "checked" attribute if the option is checked
optionSelected ( string $strOption, mixed $varValues ) : string Return a "selected" attribute if the option is selected
parse ( array $arrAttributes = null ) : string Parse the template file and return it as string
submitInput ( ) : boolean Return true if the widgets submits user input
validate ( ) Validate the user input and set the value

보호된 메소드들

메소드 설명
addSubmit ( ) : string Generate a submit button
getPost ( string $strKey ) : mixed Find and return a $_POST variable
isChecked ( array $arrOption ) : string Check whether an option is checked
isSelected ( array $arrOption ) : string Check whether an option is selected
isValidOption ( mixed $varInput ) : boolean Check whether an input is one of the given options
validator ( mixed $varInput ) : mixed Recursively validate an input variable

메소드 상세

__construct() 공개 메소드

Initialize the object
public __construct ( array $arrAttributes = null )
$arrAttributes array An optional attributes array

__get() 공개 메소드

Return an object property
public __get ( string $strKey ) : string
$strKey string The property name
리턴 string The property value

__isset() 공개 메소드

Check whether an object property exists
public __isset ( string $strKey ) : boolean
$strKey string The property name
리턴 boolean True if the property exists

__set() 공개 메소드

Set an object property
public __set ( string $strKey, mixed $varValue )
$strKey string The property name
$varValue mixed The property value

addAttribute() 공개 메소드

Add an attribute
public addAttribute ( string $strName, mixed $varValue )
$strName string The attribute name
$varValue mixed The attribute value

addAttributes() 공개 메소드

Take an associative array and add it to the object's attributes
public addAttributes ( array $arrAttributes )
$arrAttributes array An array of attributes

addError() 공개 메소드

Add an error message
public addError ( string $strError )
$strError string The error message

addSubmit() 보호된 메소드

Generate a submit button
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0.
protected addSubmit ( ) : string
리턴 string The submit button markup

generate() 추상적인 공개 메소드

Generate the widget and return it as string
abstract public generate ( ) : string
리턴 string The widget markup

generateLabel() 공개 메소드

Generate the label and return it as string
public generateLabel ( ) : string
리턴 string The label markup

generateWithError() 공개 메소드

Generate the widget with error message and return it as string
public generateWithError ( boolean $blnSwitchOrder = false ) : string
$blnSwitchOrder boolean If true, the error message will be shown below the field
리턴 string The form field markup

getAttribute() 공개 메소드

Return a single attribute
public getAttribute ( string $strKey ) : string
$strKey string The attribute name
리턴 string The attribute markup

getAttributes() 공개 메소드

Return all attributes as string
public getAttributes ( array $arrStrip = [] ) : string
$arrStrip array An optional array with attributes to strip
리턴 string The attributes string

getAttributesFromDca() 공개 정적인 메소드

Extract the Widget attributes from a Data Container array
public static getAttributesFromDca ( array $arrData, string $strName, mixed $varValue = null, string $strField = '', string $strTable = '', DataContainer | null $objDca = null ) : array
$arrData array The field configuration array
$strName string The field name in the form
$varValue mixed The field value
$strField string The field name in the database
$strTable string The table name in the database
$objDca DataContainer | null An optional DataContainer object
리턴 array An attributes array that can be passed to a widget

getEmptyStringOrNull() 공개 메소드

Return either an empty string or null based on the SQL string
public getEmptyStringOrNull ( ) : string | integer | null
리턴 string | integer | null The empty value

getEmptyStringOrNullByFieldType() 공개 정적인 메소드

Return either an empty string or null based on the SQL string
public static getEmptyStringOrNullByFieldType ( string $sql ) : string | null
$sql string The SQL string
리턴 string | null The empty string or null

getEmptyValue() 공개 메소드

Return the empty value based on the SQL string
public getEmptyValue ( ) : string | integer | null
리턴 string | integer | null The empty value

getEmptyValueByFieldType() 공개 정적인 메소드

Return the empty value based on the SQL string
public static getEmptyValueByFieldType ( string $sql ) : string | integer | null
$sql string The SQL string
리턴 string | integer | null The empty value

getErrorAsHTML() 공개 메소드

Return a particular error as HTML string
public getErrorAsHTML ( integer $intIndex ) : string
$intIndex integer The message index
리턴 string The HTML markup of the corresponding error message

getErrorAsString() 공개 메소드

Return a particular error as string
public getErrorAsString ( integer $intIndex ) : string
$intIndex integer The message index
리턴 string The corresponding error message

getErrors() 공개 메소드

Return the errors array
public getErrors ( ) : array
리턴 array An array of error messages

getErrorsAsString() 공개 메소드

Return all errors as string separated by a given separator
public getErrorsAsString ( string $strSeparator = null ) : string
$strSeparator string An optional separator (defaults to "
")
리턴 string The error messages string

getPost() 보호된 메소드

Find and return a $_POST variable
protected getPost ( string $strKey ) : mixed
$strKey string The variable name
리턴 mixed The variable value

hasErrors() 공개 메소드

Return true if the widget has errors
public hasErrors ( ) : boolean
리턴 boolean True if there are errors

isChecked() 보호된 메소드

Check whether an option is checked
protected isChecked ( array $arrOption ) : string
$arrOption array The options array
리턴 string The "checked" attribute or an empty string

isSelected() 보호된 메소드

Check whether an option is selected
protected isSelected ( array $arrOption ) : string
$arrOption array The options array
리턴 string The "selected" attribute or an empty string

isValidOption() 보호된 메소드

Check whether an input is one of the given options
protected isValidOption ( mixed $varInput ) : boolean
$varInput mixed The input string or array
리턴 boolean True if the selected option exists

optionChecked() 공개 정적인 메소드

Return a "checked" attribute if the option is checked
public static optionChecked ( string $strOption, mixed $varValues ) : string
$strOption string The option to check
$varValues mixed One or more values to check against
리턴 string The attribute or an empty string

optionSelected() 공개 정적인 메소드

Return a "selected" attribute if the option is selected
public static optionSelected ( string $strOption, mixed $varValues ) : string
$strOption string The option to check
$varValues mixed One or more values to check against
리턴 string The attribute or an empty string

parse() 공개 메소드

Parse the template file and return it as string
public parse ( array $arrAttributes = null ) : string
$arrAttributes array An optional attributes array
리턴 string The template markup

submitInput() 공개 메소드

Return true if the widgets submits user input
public submitInput ( ) : boolean
리턴 boolean True if the widget submits user input

validate() 공개 메소드

Validate the user input and set the value
public validate ( )

validator() 보호된 메소드

Recursively validate an input variable
protected validator ( mixed $varInput ) : mixed
$varInput mixed The user input
리턴 mixed The original or modified user input

프로퍼티 상세

$arrAttributes 보호되어 있는 프로퍼티

Attributes
protected array $arrAttributes
리턴 array

$arrConfiguration 보호되어 있는 프로퍼티

Configuration
protected array $arrConfiguration
리턴 array

$arrErrors 보호되어 있는 프로퍼티

Errors
protected array $arrErrors
리턴 array

$arrOptions 보호되어 있는 프로퍼티

Options
protected array $arrOptions
리턴 array

$blnForAttribute 보호되어 있는 프로퍼티

For attribute indicator
protected bool $blnForAttribute
리턴 boolean

$blnSubmitInput 보호되어 있는 프로퍼티

Submit indicator
protected bool $blnSubmitInput
리턴 boolean

$objDca 보호되어 있는 프로퍼티

Data container
protected object $objDca
리턴 object

$strClass 보호되어 있는 프로퍼티

CSS class
protected string $strClass
리턴 string

$strId 보호되어 있는 프로퍼티

Id
protected int $strId
리턴 integer

$strLabel 보호되어 있는 프로퍼티

Label
protected string $strLabel
리턴 string

$strName 보호되어 있는 프로퍼티

Name
protected string $strName
리턴 string

$strPrefix 보호되어 있는 프로퍼티

CSS class prefix
protected string $strPrefix
리턴 string

$strWizard 보호되어 있는 프로퍼티

Wizard
protected string $strWizard
리턴 string

$varValue 보호되어 있는 프로퍼티

Value
protected mixed $varValue
리턴 mixed