SimpleForm::submitImage PHP 메소드

submitImage() 공개 메소드

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.
리턴 SimpleEncoding Submitted values or false if there is no such button in the form.
    public function submitImage(SelectorInterface $selector, $x, $y, $additional = false)
    {
        $additional = $additional ? $additional : array();
        foreach ($this->images as $image) {
            if ($selector->isMatch($image)) {
                $encoding = $this->encode();
                $image->write($encoding, $x, $y);
                if ($additional) {
                    $encoding->merge($additional);
                }
                return $encoding;
            }
        }
        return false;
    }

Usage Example

예제 #1
0
 function testImageSubmitButtonWithAdditionalData()
 {
     $form = new SimpleForm(new SimpleFormTag(array()), new SimpleUrl('htp://host'));
     $form->addWidget(new SimpleImageSubmitTag(array('type' => 'image', 'src' => 'source.jpg', 'name' => 'go', 'alt' => 'Go!')));
     $this->assertEqual($form->submitImage(new SimpleByLabel('Go!'), 100, 101, array('a' => 'A')), new SimpleGetEncoding(array('go.x' => 100, 'go.y' => 101, 'a' => 'A')));
 }