Beispiel #1
0
 /**
  * @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;
 }
Beispiel #2
0
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * 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));
 }
 /**
  * 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>';
 }
Beispiel #5
0
 /**
  * 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;
 }