當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormInterface::getAttributes方法代碼示例

本文整理匯總了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;
 }
開發者ID:hanif,項目名稱:stokq,代碼行數:14,代碼來源:Form.php

示例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;
 }
開發者ID:rumeau,項目名稱:zf-twitter-bootstrap,代碼行數:36,代碼來源:Form.php

示例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));
 }
開發者ID:tillk,項目名稱:vufind,代碼行數:18,代碼來源:Form.php

示例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>';
 }
開發者ID:CHRISTOPHERVANDOMME,項目名稱:zf2complet,代碼行數:25,代碼來源:Form.php

示例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;
 }
開發者ID:skpd,項目名稱:bootstrap,代碼行數:27,代碼來源:Form.php


注:本文中的Zend\Form\FormInterface::getAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。