PHP Class Prado\Web\UI\WebControls\TTextBox

TTextBox displays a text box on the Web page for user input. The text displayed in the TTextBox control is determined by the {@link setText Text} property. You can create a SingleLine, a MultiLine, or a Password text box by setting the {@link setTextMode TextMode} property. If the TTextBox control is a multiline text box, the number of rows it displays is determined by the {@link setRows Rows} property, and the {@link setWrap Wrap} property can be used to determine whether to wrap the text in the component. Additional {@link setTextMode TextMode} types enable the use of new input types added with html5, eg. Color, Date, Email. To specify the display width of the text box, in characters, set the {@link setColumns Columns} property. To prevent the text displayed in the component from being modified, set the {@link setReadOnly ReadOnly} property to true. If you want to limit the user input to a specified number of characters, set the {@link setMaxLength MaxLength} property. To use AutoComplete feature, set the {@link setAutoCompleteType AutoCompleteType} property. If {@link setAutoPostBack AutoPostBack} is set true, updating the text box and then changing the focus out of it 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}. WARNING: Be careful if you want to display the text collected via TTextBox. Malicious cross-site script may be injected in. You may use {@link getSafeText SafeText} to prevent this problem. NOTE: If you set {@link setWrap Wrap} to false or use {@link setAutoCompleteType AutoCompleteType}, the generated HTML output for the textbox will not be XHTML-compatible. Currently, no alternatives are available.
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends TWebControl, implements Prado\Web\UI\IPostBackDataHandler, implements Prado\Web\UI\IValidatable, implements Prado\IDataRenderer
Mostrar archivo Open project: pradosoft/prado Class Usage Examples

Public Methods

Method Description
getAutoCompleteType ( ) : TTextBoxAutoCompleteType
getAutoPostBack ( ) : boolean
getAutoTrim ( ) : boolean
getCausesValidation ( ) : boolean
getColumns ( ) : integer
getData ( ) : string Returns the text content of the TTextBox control.
getDataChanged ( ) : boolean Returns a value indicating whether postback has caused the control data change.
getEnableClientScript ( ) : boolean
getIsValid ( ) : boolean Returns true if this control validated successfully.
getMaxLength ( ) : integer
getPersistPassword ( ) : boolean
getReadOnly ( ) : boolean
getRows ( ) : integer
getSafeText ( ) : string
getText ( ) : string
getTextMode ( ) : TTextBoxMode
getValidationGroup ( ) : string
getValidationPropertyValue ( ) : mixed Returns the value to be validated.
getWrap ( ) : boolean
loadPostData ( $key, $values ) : boolean Loads user input data.
onTextChanged ( $param ) Raises OnTextChanged event.
raisePostDataChangedEvent ( ) Raises postdata changed event.
renderBeginTag ( $writer ) Renders an additional line-break after the opening tag when it is in MultiLine text mode.
renderContents ( $writer ) Renders the body content of the textbox when it is in MultiLine text mode.
setAutoCompleteType ( $value )
setAutoPostBack ( $value ) Sets the value indicating if postback automatically.
setAutoTrim ( $value ) Sets the value indicating if the input text should be trimmed spaces
setCausesValidation ( $value )
setColumns ( $value ) Sets the display width of the text box in characters.
setData ( $value ) Sets the text content of the TTextBox control.
setEnableClientScript ( $value )
setIsValid ( $value )
setMaxLength ( $value ) Sets the maximum number of characters allowed in the text box.
setPersistPassword ( $value )
setReadOnly ( $value )
setRows ( $value ) Sets the number of rows displayed in a multiline text box.
setText ( $value ) Sets the text content of the TTextBox control.
setTextMode ( $value ) Sets the behavior mode of the TTextBox component.
setValidationGroup ( $value )
setWrap ( $value ) Sets the value indicating whether the text content wraps within a multiline text box.

Protected Methods

Method Description
addAttributesToRender ( $writer ) Adds attribute name-value pairs to renderer.
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 textbox.
getSafeTextParser ( ) : mixed
getTagName ( ) : string
renderClientControlScript ( $writer ) Renders the javascript for textbox.

Method Details

addAttributesToRender() protected method

This method overrides the parent implementation with additional textbox specific attributes.
protected addAttributesToRender ( $writer )

getAutoCompleteType() public method

public getAutoCompleteType ( ) : TTextBoxAutoCompleteType
return TTextBoxAutoCompleteType the AutoComplete type of the textbox

getAutoPostBack() public method

public getAutoPostBack ( ) : boolean
return boolean a value indicating whether an automatic postback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component. Defaults to false.

getAutoTrim() public method

public getAutoTrim ( ) : boolean
return boolean a value indicating whether the input text should be trimmed spaces. Defaults to false.

getCausesValidation() public method

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

getClientClassName() protected method

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

getColumns() public method

public getColumns ( ) : integer
return integer the display width of the text box in characters, default is 0 meaning not set.

getData() public method

This method is required by {@link \Prado\IDataRenderer}. It is the same as {@link getText()}.
See also: getText
Since: 3.1.0
public getData ( ) : string
return string the text content of the TTextBox control.

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.

getIsValid() public method

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

getMaxLength() public method

public getMaxLength ( ) : integer
return integer the maximum number of characters allowed in the text box, default is 0 meaning not set.

getPersistPassword() public method

public getPersistPassword ( ) : boolean
return boolean whether password should be displayed in the textbox during postback. Defaults to false. This property only applies when TextMode='Password'.

getPostBackOptions() protected method

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

getReadOnly() public method

public getReadOnly ( ) : boolean
return boolean whether the textbox is read only, default is false.

getRows() public method

public getRows ( ) : integer
return integer the number of rows displayed in a multiline text box, default is 4

getSafeText() public method

public getSafeText ( ) : string
return string safe text content with javascript stripped off

getSafeTextParser() protected method

protected getSafeTextParser ( ) : mixed
return mixed safe text parser

getTagName() protected method

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

getText() public method

public getText ( ) : string
return string the text content of the TTextBox control.

getTextMode() public method

public getTextMode ( ) : TTextBoxMode
return TTextBoxMode the behavior mode of the TTextBox component. Defaults to TTextBoxMode::SingleLine.

getValidationGroup() public method

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

getValidationPropertyValue() public method

This methid is required by \Prado\Web\UI\IValidatable interface.
public getValidationPropertyValue ( ) : mixed
return mixed the value of the property to be validated.

getWrap() public method

public getWrap ( ) : boolean
return boolean whether the text content wraps within a multiline text box. Defaults to true.

loadPostData() public method

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

onTextChanged() public method

This method is invoked when the value of the {@link getText Text} property changes on postback. If you override this method, be sure to call the parent implementation to ensure the invocation of the attached event handlers.
public onTextChanged ( $param )

raisePostDataChangedEvent() public method

This method is required by {@link \Prado\Web\UI\IPostBackDataHandler} interface. It is invoked by the framework when {@link getText Text} property is changed on postback. This method is primarly used by framework developers.

renderBeginTag() public method

Renders an additional line-break after the opening tag when it is in MultiLine text mode.
public renderBeginTag ( $writer )

renderClientControlScript() protected method

Renders the javascript for textbox.
protected renderClientControlScript ( $writer )

renderContents() public method

Renders the body content of the textbox when it is in MultiLine text mode.
public renderContents ( $writer )

setAutoCompleteType() public method

public setAutoCompleteType ( $value )

setAutoPostBack() public method

An automatic postback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component.
public setAutoPostBack ( $value )

setAutoTrim() public method

Sets the value indicating if the input text should be trimmed spaces
public setAutoTrim ( $value )

setCausesValidation() public method

public setCausesValidation ( $value )

setColumns() public method

Sets the display width of the text box in characters.
public setColumns ( $value )

setData() public method

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

setEnableClientScript() public method

public setEnableClientScript ( $value )

setIsValid() public method

public setIsValid ( $value )

setMaxLength() public method

Sets the maximum number of characters allowed in the text box.
public setMaxLength ( $value )

setPersistPassword() public method

public setPersistPassword ( $value )

setReadOnly() public method

public setReadOnly ( $value )

setRows() public method

Sets the number of rows displayed in a multiline text box.
public setRows ( $value )

setText() public method

Sets the text content of the TTextBox control.
public setText ( $value )

setTextMode() public method

Sets the behavior mode of the TTextBox component.
public setTextMode ( $value )

setValidationGroup() public method

public setValidationGroup ( $value )

setWrap() public method

Sets the value indicating whether the text content wraps within a multiline text box.
public setWrap ( $value )