PHP Class Prado\Web\UI\WebControls\TCheckBox

TCheckBox displays a check box on the page. You can specify the caption to display beside the check box by setting the {@link setText Text} property. The caption can appear either on the right or left of the check box, which is determined by the {@link setTextAlign TextAlign} property. To determine whether the TCheckBox component is checked, test the {@link getChecked Checked} property. The {@link onCheckedChanged OnCheckedChanged} event is raised when the {@link getChecked Checked} state of the TCheckBox component changes between posts to the server. You can provide an event handler for the {@link onCheckedChanged OnCheckedChanged} event to to programmatically control the actions performed when the state of the TCheckBox component changes between posts to the server. If {@link setAutoPostBack AutoPostBack} is set true, changing the check box state will cause postback action. And if {@link setCausesValidation CausesValidation} is true, validation will also be processed, which can be further restricted within a {@link setValidationGroup ValidationGroup}. Note, {@link setText Text} is rendered as is. Make sure it does not contain unwanted characters that may bring security vulnerabilities.
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends TWebControl, implements Prado\Web\UI\IPostBackDataHandler, implements Prado\Web\UI\IValidatable, implements Prado\IDataRenderer, implements Prado\Web\UI\ISurroundable
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Méthodes publiques

Méthode Description
getAutoPostBack ( ) : boolean
getCausesValidation ( ) : boolean
getChecked ( ) : boolean
getData ( ) : boolean Returns the value indicating whether the checkbox is checked.
getDataChanged ( ) : boolean Returns a value indicating whether postback has caused the control data change.
getEnableClientScript ( ) : boolean
getInputAttributes ( ) : TMap
getIsValid ( ) : boolean Returns true if this control validated successfully.
getLabelAttributes ( ) : TMap
getSurroundingTag ( ) : string
getSurroundingTagID ( ) : string
getText ( ) : string
getTextAlign ( ) : TTextAlign
getValidationGroup ( ) : string
getValidationPropertyValue ( ) : mixed Returns the value of the property that needs validation.
getValue ( ) : string
loadPostData ( $key, $values ) : boolean Loads user input data.
onCheckedChanged ( $param ) Raises OnCheckedChanged event when {@link getChecked Checked} changes value during postback.
onPreRender ( $param ) Registers the checkbox to receive postback data during postback.
raisePostDataChangedEvent ( ) Raises postdata changed event.
render ( $writer ) Renders the checkbox control.
setAutoPostBack ( $value ) Sets a value indicating whether clicking on the checkbox will post the page.
setCausesValidation ( $value ) Sets the value indicating whether postback event trigger by this checkbox will cause input validation.
setChecked ( $value ) Sets a value indicating whether the checkbox is to be checked or not.
setData ( $value ) Sets the value indicating whether the checkbox is to be checked or not.
setEnableClientScript ( $value )
setIsValid ( $value )
setText ( $value ) Sets the text caption of the checkbox.
setTextAlign ( $value )
setValidationGroup ( $value )
setValue ( $value )

Méthodes protégées

Méthode Description
getClientClassName ( ) : string Gets the name of the javascript class responsible for performing postback for this control.
getPostBackOptions ( ) : array Gets the post back options for this checkbox.
getSpanNeeded ( ) : boolean Check if we need a span tag to surround this control. The span tag will be created if the Text property is set for this control.
getTagName ( ) : string
getValueAttribute ( ) : string
renderClientControlScript ( $writer ) Renders the client-script code.
renderInputTag ( $writer, $clientID, $onclick ) Renders a checkbox input element.
renderLabel ( $writer, $clientID, $text ) Renders a label beside the checkbox.

Method Details

getAutoPostBack() public méthode

public getAutoPostBack ( ) : boolean
Résultat boolean whether clicking on the checkbox will post the page.

getCausesValidation() public méthode

public getCausesValidation ( ) : boolean
Résultat boolean whether postback event triggered by this checkbox will cause input validation, default is true.

getChecked() public méthode

public getChecked ( ) : boolean
Résultat boolean whether the checkbox is checked

getClientClassName() protected méthode

This method overrides the parent implementation.
protected getClientClassName ( ) : string
Résultat string the javascript class name

getData() public méthode

This method is required by {@link \Prado\IDataRenderer}. It is the same as {@link getChecked()}.
See also: getChecked
Since: 3.1.0
public getData ( ) : boolean
Résultat boolean whether the checkbox is checked.

getDataChanged() public méthode

This method is required by the \Prado\Web\UI\IPostBackDataHandler interface.
public getDataChanged ( ) : boolean
Résultat boolean whether postback has caused the control data change. False if the page is not in postback mode.

getEnableClientScript() public méthode

public getEnableClientScript ( ) : boolean
Résultat boolean whether to render javascript.

getInputAttributes() public méthode

public getInputAttributes ( ) : TMap
Résultat TMap list of attributes to be rendered for the checkbox

getIsValid() public méthode

Defaults to true.
public getIsValid ( ) : boolean
Résultat boolean wether this control validated successfully.

getLabelAttributes() public méthode

public getLabelAttributes ( ) : TMap
Résultat TMap list of attributes to be rendered for label beside the checkbox

getPostBackOptions() protected méthode

Gets the post back options for this checkbox.
protected getPostBackOptions ( ) : array
Résultat array

getSpanNeeded() protected méthode

Check if we need a span tag to surround this control. The span tag will be created if the Text property is set for this control.
protected getSpanNeeded ( ) : boolean
Résultat boolean wether this control needs a surrounding span tag

getSurroundingTag() public méthode

public getSurroundingTag ( ) : string
Résultat string the tag used to wrap the control in.

getSurroundingTagID() public méthode

public getSurroundingTagID ( ) : string
Résultat string the id of the surrounding tag or this clientID if no such tag needed.

getTagName() protected méthode

protected getTagName ( ) : string
Résultat string tag name of the button

getText() public méthode

public getText ( ) : string
Résultat string the text caption of the checkbox

getTextAlign() public méthode

public getTextAlign ( ) : TTextAlign
Résultat TTextAlign the alignment (Left or Right) of the text caption, defaults to TTextAlign::Right.

getValidationGroup() public méthode

public getValidationGroup ( ) : string
Résultat string the group of validators which the checkbox causes validation upon postback

getValidationPropertyValue() public méthode

Returns the value of the property that needs validation.
public getValidationPropertyValue ( ) : mixed
Résultat mixed the property value to be validated

getValue() public méthode

public getValue ( ) : string
Résultat string the value of the checkbox. Defaults to empty.

getValueAttribute() protected méthode

protected getValueAttribute ( ) : string
Résultat string the value attribute to be rendered

loadPostData() public méthode

This method is primarly used by framework developers.
public loadPostData ( $key, $values ) : boolean
Résultat boolean whether the data of the control has been changed

onCheckedChanged() public méthode

If you override this method, be sure to call the parent implementation so that the event delegates can be invoked.
public onCheckedChanged ( $param )

onPreRender() public méthode

This is necessary because a checkbox if unchecked, when postback, does not have direct mapping between post data and the checkbox name. This method overrides the parent implementation and is invoked before render.
public onPreRender ( $param )

raisePostDataChangedEvent() public méthode

This method raises {@link onCheckedChanged OnCheckedChanged} event. This method is primarly used by framework developers.

render() public méthode

This method overrides the parent implementation by rendering a checkbox input element and a span element if needed.
public render ( $writer )

renderClientControlScript() protected méthode

Renders the client-script code.
protected renderClientControlScript ( $writer )

renderInputTag() protected méthode

Renders a checkbox input element.
protected renderInputTag ( $writer, $clientID, $onclick )

renderLabel() protected méthode

Renders a label beside the checkbox.
protected renderLabel ( $writer, $clientID, $text )

setAutoPostBack() public méthode

Sets a value indicating whether clicking on the checkbox will post the page.
public setAutoPostBack ( $value )

setCausesValidation() public méthode

Sets the value indicating whether postback event trigger by this checkbox will cause input validation.
public setCausesValidation ( $value )

setChecked() public méthode

Sets a value indicating whether the checkbox is to be checked or not.
public setChecked ( $value )

setData() public méthode

This method is required by {@link \Prado\IDataRenderer}. It is the same as {@link setChecked()}.
See also: setChecked
Since: 3.1.0
public setData ( $value )

setEnableClientScript() public méthode

public setEnableClientScript ( $value )

setIsValid() public méthode

public setIsValid ( $value )

setText() public méthode

Sets the text caption of the checkbox.
public setText ( $value )

setTextAlign() public méthode

public setTextAlign ( $value )

setValidationGroup() public méthode

public setValidationGroup ( $value )

setValue() public méthode

public setValue ( $value )