SimpleForm::hasImage PHP 메소드

hasImage() 공개 메소드

Test to see if a form has an image control.
public hasImage ( SelectorInterface $selector ) : boolean
$selector SelectorInterface Criteria to apply.
리턴 boolean True if present.
    public function hasImage(SelectorInterface $selector)
    {
        foreach ($this->images as $image) {
            if ($selector->isMatch($image)) {
                return true;
            }
        }
        return false;
    }

Usage Example

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