本文整理汇总了PHP中Zend\Form\FormInterface::hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::hasAttribute方法的具体用法?PHP FormInterface::hasAttribute怎么用?PHP FormInterface::hasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::hasAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* @param string $content
* @param array $attribs
* @param ElementInterface $element
* @param FormInterface $form
* @return string
*/
public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
{
if ($form && $form->hasAttribute('class')) {
$class = $form->getAttribute('class');
if (strpos($class, 'form-inline') !== false) {
return $content;
}
}
return parent::render($content, $attribs);
}
示例2: setHorizontal
/**
* @param FormInterface|null $form
*/
private function setHorizontal($form)
{
if ($this->isHorizontal && $form !== null) {
if ($form->hasAttribute('class')) {
$form->setAttribute('class', 'form-horizontal ' . $form->getAttribute('class'));
} else {
$form->setAttribute('class', 'form-horizontal');
}
}
}
示例3: openTag
/**
* {@inheritDoc}
*/
public function openTag(FormInterface $form = null)
{
if ($form) {
if (!$form->hasAttribute('role')) {
$form->setAttribute('role', 'form');
}
$class = $form->getAttribute('class');
if (strpos($class, 'form-horizontal') === false && strpos($class, 'form-inline') === false) {
$form->setAttribute('class', trim("{$this->defaultClass} {$class}"));
}
}
return parent::openTag($form);
}
示例4: render
/**
* @param string $content
* @param array $attribs
* @param ElementInterface $element
* @param FormInterface $form
* @return string
*/
public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
{
if ($form && $form->hasAttribute('class')) {
$class = $form->getAttribute('class');
if (strpos($class, 'form-inline') !== false) {
return $content;
}
if (strpos($class, 'form-horizontal') !== false && empty($attribs['class']) && $form->has('submit') && $form->has('reset')) {
if ($form->get('submit') === $element) {
$attribs['class'] = 'col-xs-12 col-sm-8';
} elseif ($form->get('reset') === $element) {
$attribs['class'] = 'col-xs-12 col-sm-4';
}
}
}
return parent::render($content, $attribs);
}