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
Datei anzeigen Open project: pradosoft/prado Class Usage Examples

Public Methods

Method 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 )

Protected Methods

Method 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 method

public getAutoPostBack ( ) : boolean
return boolean whether clicking on the checkbox will post the page.

getCausesValidation() public method

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

getChecked() public method

public getChecked ( ) : boolean
return boolean whether the checkbox is checked

getClientClassName() protected method

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

getData() public method

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
return boolean whether the checkbox is checked.

getDataChanged() public method

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

getEnableClientScript() public method

public getEnableClientScript ( ) : boolean
return boolean whether to render javascript.

getInputAttributes() public method

public getInputAttributes ( ) : TMap
return TMap list of attributes to be rendered for the checkbox

getIsValid() public method

Defaults to true.
public getIsValid ( ) : boolean
return boolean wether this control validated successfully.

getLabelAttributes() public method

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

getPostBackOptions() protected method

Gets the post back options for this checkbox.
protected getPostBackOptions ( ) : array
return array

getSpanNeeded() protected method

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
return boolean wether this control needs a surrounding span tag

getSurroundingTag() public method

public getSurroundingTag ( ) : string
return string the tag used to wrap the control in.

getSurroundingTagID() public method

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

getTagName() protected method

protected getTagName ( ) : string
return string tag name of the button

getText() public method

public getText ( ) : string
return string the text caption of the checkbox

getTextAlign() public method

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

getValidationGroup() public method

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

getValidationPropertyValue() public method

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

getValue() public method

public getValue ( ) : string
return string the value of the checkbox. Defaults to empty.

getValueAttribute() protected method

protected getValueAttribute ( ) : string
return string the value attribute to be rendered

loadPostData() public method

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

onCheckedChanged() public method

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 method

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 method

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

render() public method

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

renderClientControlScript() protected method

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

renderInputTag() protected method

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

renderLabel() protected method

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

setAutoPostBack() public method

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

setCausesValidation() public method

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

setChecked() public method

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

setData() public method

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 method

public setEnableClientScript ( $value )

setIsValid() public method

public setIsValid ( $value )

setText() public method

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

setTextAlign() public method

public setTextAlign ( $value )

setValidationGroup() public method

public setValidationGroup ( $value )

setValue() public method

public setValue ( $value )