本文整理汇总了PHP中Zend\Form\Element\Select::getInputSpecification方法的典型用法代码示例。如果您正苦于以下问题:PHP Select::getInputSpecification方法的具体用法?PHP Select::getInputSpecification怎么用?PHP Select::getInputSpecification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element\Select
的用法示例。
在下文中一共展示了Select::getInputSpecification方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInputSpecification
public function getInputSpecification()
{
$spec = parent::getInputSpecification();
$spec['allow_empty'] = true;
$spec['filters'] = [new NullFilter(NullFilter::TYPE_STRING)];
return $spec;
}
示例2: testInArrayValidationOfOptions
/**
* @dataProvider selectOptionsDataProvider
*/
public function testInArrayValidationOfOptions($valueTests, $options)
{
$element = new SelectElement('my-select');
$element->setAttributes(array('options' => $options));
$inputSpec = $element->getInputSpecification();
$this->assertArrayHasKey('validators', $inputSpec);
$inArrayValidator = $inputSpec['validators'][0];
$this->assertInstanceOf('Zend\\Validator\\InArray', $inArrayValidator);
foreach ($valueTests as $valueToTest) {
$this->assertTrue($inArrayValidator->isValid($valueToTest));
}
}
示例3: testProvidesInputSpecificationForMultipleSelect
public function testProvidesInputSpecificationForMultipleSelect()
{
$element = new SelectElement();
$element->setAttributes(array('multiple' => true, 'options' => array('Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3')));
$inputSpec = $element->getInputSpecification();
$this->assertArrayHasKey('validators', $inputSpec);
$this->assertInternalType('array', $inputSpec['validators']);
$expectedClasses = array('Zend\\Validator\\Explode');
foreach ($inputSpec['validators'] as $validator) {
$class = get_class($validator);
$this->assertTrue(in_array($class, $expectedClasses), $class);
switch ($class) {
case 'Zend\\Validator\\Explode':
$this->assertInstanceOf('Zend\\Validator\\InArray', $validator->getValidator());
break;
default:
break;
}
}
}
示例4: testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes
public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes()
{
$element = new SelectElement();
$element->setAttribute('options', array('Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3'));
$inputSpec = $element->getInputSpecification();
$this->assertArrayHasKey('validators', $inputSpec);
$this->assertInternalType('array', $inputSpec['validators']);
$expectedClasses = array('Zend\\Validator\\InArray');
foreach ($inputSpec['validators'] as $validator) {
$class = get_class($validator);
$this->assertTrue(in_array($class, $expectedClasses), $class);
switch ($class) {
case 'Zend\\Validator\\InArray':
$this->assertEquals($element->getAttribute('options'), $validator->getHaystack());
break;
default:
break;
}
}
}
示例5: testDisableInputSpecification
public function testDisableInputSpecification()
{
$element = new SelectElement();
$element->setValueOptions(array('Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3'));
$element->setDisableInArrayValidator(true);
$inputSpec = $element->getInputSpecification();
$this->assertArrayNotHasKey('validators', $inputSpec);
}
示例6: testInArrayValidatorHaystakIsUpdated
/**
* Testing that InArray Validator Haystack is Updated if the Options
* are added after the validator is attached
*
* @dataProvider selectOptionsDataProvider
*/
public function testInArrayValidatorHaystakIsUpdated($valueTests, $options)
{
$element = new SelectElement('my-select');
$inputSpec = $element->getInputSpecification();
$inArrayValidator = $inputSpec['validators'][0];
$this->assertInstanceOf('Zend\\Validator\\InArray', $inArrayValidator);
$element->setValueOptions($options);
$haystack = $inArrayValidator->getHaystack();
$this->assertCount(count($options), $haystack);
}
示例7: testProvidesInputSpecificationForMultipleSelectWithUseHiddenElement
public function testProvidesInputSpecificationForMultipleSelectWithUseHiddenElement()
{
$element = new SelectElement();
$element->setUseHiddenElement(true)->setAttributes(array('multiple' => true));
$inputSpec = $element->getInputSpecification();
$this->assertArrayHasKey('allow_empty', $inputSpec);
$this->assertTrue($inputSpec['allow_empty']);
$this->assertArrayHasKey('continue_if_empty', $inputSpec);
$this->assertTrue($inputSpec['continue_if_empty']);
}
示例8: getInputSpecification
/**
* {@inheritDoc}
*/
public function getInputSpecification()
{
$inputSpec = parent::getInputSpecification();
$defaultFilters = [['name' => 'StringTrim']];
if (isset($inputSpec['filters'])) {
array_unshift($inputSpec['filters'], $defaultFilters);
} else {
$inputSpec['filters'] = $defaultFilters;
}
return $inputSpec;
}