本文整理汇总了PHP中Zend\Form\FormInterface::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::getAttributes方法的具体用法?PHP FormInterface::getAttributes怎么用?PHP FormInterface::getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::getAttributes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: open
/**
* @return string
*/
public function open()
{
$defaultAttributes = ['action' => '', 'method' => 'post'];
$attributes = $this->form->getAttributes();
if (!array_key_exists('id', $attributes) && array_key_exists('name', $attributes)) {
$attributes['id'] = $attributes['name'];
}
$attributes = array_merge($defaultAttributes, $attributes);
$tag = sprintf('<form %s>', new Attributes($attributes));
return $tag;
}
示例2: openTag
/**
* Generate an opening form tag
*
* @param null|FormInterface $form
* @return string
*/
public function openTag(FormInterface $form = null)
{
$attributes = array('action' => '', 'method' => 'get');
if ($form instanceof FormInterface) {
$formAttributes = $form->getAttributes();
if (array_key_exists('class', $formAttributes) && !empty($formAttributes['class'])) {
$formAttributes['class'] = $formAttributes['class'] . ' ';
} else {
$formAttributes['class'] = '';
}
switch ($form->getFormLayout()) {
case FormInstance::FORM_LAYOUT_SEARCH:
$formAttributes['class'] .= 'form-search';
break;
case FormInstance::FORM_LAYOUT_INLINE:
$formAttributes['class'] .= 'form-inline';
break;
case FormInstance::FORM_LAYOUT_HORIZONTAL:
default:
$formAttributes['class'] .= 'form-horizontal';
break;
}
if (!array_key_exists('id', $formAttributes) && array_key_exists('name', $formAttributes)) {
$formAttributes['id'] = $formAttributes['name'];
}
$attributes = array_merge($attributes, $formAttributes);
}
$tag = sprintf('<form %s>', $this->createAttributesString($attributes));
return $tag;
}
示例3: openTag
/**
* Generate an opening form tag
*
* @param null|FormInterface $form
* @return string
*/
public function openTag(FormInterface $form = null)
{
$attributes = array('action' => '', 'method' => 'get');
if ($form instanceof FormInterface) {
$formAttributes = $form->getAttributes();
if (!array_key_exists('id', $formAttributes) && array_key_exists('name', $formAttributes)) {
$formAttributes['id'] = $formAttributes['name'];
}
$attributes = array_merge($attributes, $formAttributes);
}
return sprintf('<form %s>', $this->createAttributesString($attributes));
}
示例4: openTag
/**
* Generate an opening form tag
*
* @param null|FormInterface $form
* @return string
*/
public function openTag(FormInterface $form = null)
{
$doctype = $this->getDoctype();
$attributes = [];
if (!(Doctype::HTML5 === $doctype || Doctype::XHTML5 === $doctype)) {
$attributes = ['action' => '', 'method' => 'get'];
}
if ($form instanceof FormInterface) {
$formAttributes = $form->getAttributes();
if (!array_key_exists('id', $formAttributes) && array_key_exists('name', $formAttributes)) {
$formAttributes['id'] = $formAttributes['name'];
}
$attributes = array_merge($attributes, $formAttributes);
}
if ($attributes) {
return sprintf('<form %s>', $this->createAttributesString($attributes));
}
return '<form>';
}
示例5: openTag
/**
* Generate an opening form tag
*
* @param FormInterface $form
* @return string
*/
public function openTag(FormInterface $form = null)
{
$attributes = array('action' => '', 'method' => 'get', 'role' => 'form');
if ($form instanceof FormInterface) {
$formAttributes = $form->getAttributes();
if (!array_key_exists('id', $formAttributes) && array_key_exists('name', $formAttributes)) {
$formAttributes['id'] = $formAttributes['name'];
}
$attributes = array_merge($attributes, $formAttributes);
}
if (!empty($this->type) && !empty($this->validTypes[$this->type])) {
if (isset($attributes['class'])) {
$attributes['class'] = $attributes['class'] . ' ';
} else {
$attributes['class'] = '';
}
$attributes['class'] .= 'form-' . $this->type;
}
$tag = sprintf('<form %s>', $this->createAttributesString($attributes));
return $tag;
}