SimpleForm::getValue PHP 메소드

getValue() 공개 메소드

Extracts current value from form.
public getValue ( SelectorInterface $selector ) : string/array
$selector SelectorInterface Criteria to apply.
리턴 string/array
    public function getValue(SelectorInterface $selector)
    {
        for ($i = 0, $count = count($this->widgets); $i < $count; $i++) {
            if ($selector->isMatch($this->widgets[$i])) {
                return $this->widgets[$i]->getValue();
            }
        }
        foreach ($this->buttons as $button) {
            if ($selector->isMatch($button)) {
                return $button->getValue();
            }
        }
        return;
    }

Usage Example

예제 #1
0
 function testMultipleFieldsWithSameKey()
 {
     $form = new SimpleForm(new SimpleFormTag(array()), new SimpleUrl('htp://host'));
     $form->addWidget(new SimpleCheckboxTag(array('name' => 'a', 'type' => 'checkbox', 'value' => 'me')));
     $form->addWidget(new SimpleCheckboxTag(array('name' => 'a', 'type' => 'checkbox', 'value' => 'you')));
     $this->assertIdentical($form->getValue(new SimpleByName('a')), false);
     $this->assertTrue($form->setField(new SimpleByName('a'), 'me'));
     $this->assertIdentical($form->getValue(new SimpleByName('a')), 'me');
 }