PHP Class SimpleForm, simpletest

ファイルを表示 Open project: simpletest/simpletest Class Usage Examples

Public Methods

Method Description
__construct ( SimpleTag $tag, SimplePage $page ) Starts with no held controls/widgets.
addWidget ( SimpleWidget $tag ) Adds a tag contents to the form.
attachLabelBySelector ( SelectorInterface $selector, $label ) Used by the page object to set widgets labels to external label tags.
getAction ( ) : SimpleUrl Absolute URL of the target.
getId ( ) : string ID field of form for unique identification.
getMethod ( ) : string Accessor for method of form submission.
getValue ( SelectorInterface $selector ) : string/array Extracts current value from form.
hasImage ( SelectorInterface $selector ) : boolean Test to see if a form has an image control.
hasSubmit ( SelectorInterface $selector ) : boolean Test to see if a form has a submit button.
setDefaultTarget ( string $frame ) Sets the frame target within a frameset.
setField ( SelectorInterface $selector, string $value, $position = false ) : boolean Sets a widget value within the form.
submit ( $additional = false ) : hash Simply submits the form without the submit button value.
submitButton ( SelectorInterface $selector, hash $additional = false ) : SimpleEncoding Gets the submit values for a selected button.
submitImage ( SelectorInterface $selector, integer $x, integer $y, hash $additional = false ) : SimpleEncoding Gets the submit values for an image.

Protected Methods

Method Description
addCheckbox ( SimpleCheckboxTag $tag ) Adds a checkbox, making it a group on a repeated name.
addRadioButton ( SimpleRadioButtonTag $tag ) Adds a radio button, building a group if necessary.
createAction ( string $action, $page ) : SimpleUrl Combined action attribute with current location to get an absolute form target.
encode ( ) : SimpleFormEncoding Creates the encoding for the current values in the form.
setEncodingClass ( SimpleTag $tag ) : string Creates the request packet to be sent by the form.
setWidget ( SimpleWidget $tag ) Sets the widget into the form, grouping radio buttons if any.

Method Details

__construct() public method

Starts with no held controls/widgets.
public __construct ( SimpleTag $tag, SimplePage $page )
$tag SimpleTag Form tag to read.
$page SimplePage Holding page.

addCheckbox() protected method

Adds a checkbox, making it a group on a repeated name.
protected addCheckbox ( SimpleCheckboxTag $tag )
$tag SimpleCheckboxTag Incoming form control.

addRadioButton() protected method

Adds a radio button, building a group if necessary.
protected addRadioButton ( SimpleRadioButtonTag $tag )
$tag SimpleRadioButtonTag Incoming form control.

addWidget() public method

Adds a tag contents to the form.
public addWidget ( SimpleWidget $tag )
$tag SimpleWidget Input tag to add.

attachLabelBySelector() public method

Used by the page object to set widgets labels to external label tags.
public attachLabelBySelector ( SelectorInterface $selector, $label )
$selector SelectorInterface Criteria to apply.

createAction() protected method

Combined action attribute with current location to get an absolute form target.
protected createAction ( string $action, $page ) : SimpleUrl
$action string Action attribute from form tag.
$page Page location.
return SimpleUrl Absolute form target.

encode() protected method

Creates the encoding for the current values in the form.
protected encode ( ) : SimpleFormEncoding
return SimpleFormEncoding Request to submit.

getAction() public method

Absolute URL of the target.
public getAction ( ) : SimpleUrl
return SimpleUrl URL target.

getId() public method

ID field of form for unique identification.
public getId ( ) : string
return string Unique tag ID.

getMethod() public method

Accessor for method of form submission.
public getMethod ( ) : string
return string Either get or post.

getValue() public method

Extracts current value from form.
public getValue ( SelectorInterface $selector ) : string/array
$selector SelectorInterface Criteria to apply.
return string/array

hasImage() public method

Test to see if a form has an image control.
public hasImage ( SelectorInterface $selector ) : boolean
$selector SelectorInterface Criteria to apply.
return boolean True if present.

hasSubmit() public method

Test to see if a form has a submit button.
public hasSubmit ( SelectorInterface $selector ) : boolean
$selector SelectorInterface Criteria to apply.
return boolean True if present.

setDefaultTarget() public method

Sets the frame target within a frameset.
public setDefaultTarget ( string $frame )
$frame string Name of frame.

setEncodingClass() protected method

Creates the request packet to be sent by the form.
protected setEncodingClass ( SimpleTag $tag ) : string
$tag SimpleTag Form tag to read.
return string Packet class.

setField() public method

Sets a widget value within the form.
public setField ( SelectorInterface $selector, string $value, $position = false ) : boolean
$selector SelectorInterface Criteria to apply.
$value string Value to input into the widget.
return boolean True if value is legal, false otherwise. If the field is not present, nothing will be set.

setWidget() protected method

Sets the widget into the form, grouping radio buttons if any.
protected setWidget ( SimpleWidget $tag )
$tag SimpleWidget Incoming form control.

submit() public method

Used when there is only one button or it is unimportant.
public submit ( $additional = false ) : hash
return hash Submitted values.

submitButton() public method

Gets the submit values for a selected button.
public submitButton ( SelectorInterface $selector, hash $additional = false ) : SimpleEncoding
$selector SelectorInterface Criteria to apply.
$additional hash Additional data for the form.
return SimpleEncoding Submitted values or false if there is no such button in the form.

submitImage() public method

Gets the submit values for an image.
public submitImage ( SelectorInterface $selector, integer $x, integer $y, hash $additional = false ) : SimpleEncoding
$selector SelectorInterface Criteria to apply.
$x integer X-coordinate of click.
$y integer Y-coordinate of click.
$additional hash Additional data for the form.
return SimpleEncoding Submitted values or false if there is no such button in the form.