本文整理匯總了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);
}