本文整理汇总了PHP中Zend\Form\Element::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::getAttribute方法的具体用法?PHP Element::getAttribute怎么用?PHP Element::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element
的用法示例。
在下文中一共展示了Element::getAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createElement
protected function createElement(ZendElement $element, $attr = array())
{
if ($element instanceof Element && $element->getAttribute('type') == 'hidden') {
return parent::createElement($element, $attr);
}
return '<div class="controls">' . parent::createElement($element, $attr) . '</div>';
}
示例2: getAttribute
/**
* Override: retrieve a single element attribute
*
* Retrieves validator hash when asked for 'value' attribute;
* otherwise, proxies to parent.
*
* @param string $name
* @return mixed
*/
public function getAttribute($name)
{
if ($name != 'value') {
return parent::getAttribute($name);
}
$validator = $this->getValidator();
return $validator->getHash();
}
示例3: getHtml
/**
* __invoke
*
* @param Element $formElement
* @param $instanceConfig
*
* @return string
*/
public function getHtml(Element $formElement, $instanceConfig)
{
$labelName = $inputId = $formElement->getAttribute('name');
$fieldSetParts = explode('[', $labelName);
/**
* Handle elements that came from fieldSets
*/
if (count($fieldSetParts) > 1) {
$fieldSetParts = explode(']', $fieldSetParts[1]);
$labelName = $fieldSetParts[0] . $fieldSetParts[1];
$inputId = $fieldSetParts[0];
}
$instanceConfigLabelName = $labelName . 'Label';
$text = $instanceConfig[$instanceConfigLabelName];
return '<label for="' . $inputId . '"' . (count($formElement->getMessages()) ? ' class=invalid' : '') . ' data-textEdit="' . $instanceConfigLabelName . '">' . $text . '</label>';
}
示例4: testSettingNameSetsNameAttribute
public function testSettingNameSetsNameAttribute()
{
$element = new Element();
$element->setName('foo');
$this->assertEquals('foo', $element->getAttribute('name'));
}
示例5: getAttribute
/**
* @inheritdoc
*/
public function getAttribute($key)
{
return $this->element->getAttribute($key);
}
示例6: addElementViewModel
/**
* Add elements view model to a parent view model
* @param Element $element
* @param ViewModel $parentViewModel
*/
protected function addElementViewModel(Element $element, ViewModel &$parentViewModel)
{
$elementViewModel = new ViewModel();
$type = 'text';
if ($element->getAttribute('type')) {
$type = strtolower($element->getAttribute('type'));
}
$elementTemplate = 'form/element/' . $type;
$elementViewModel->setTemplate($elementTemplate);
$elementViewModel->setVariable('element', $element);
$parentViewModel->addChild($elementViewModel, 'elements', true);
}