getMethod() public method

Returns form's method.
public getMethod ( ) : string
return string get | post
Beispiel #1
0
 /**
  * Renders form begin.
  * @return string
  */
 public function renderBegin()
 {
     $this->counter = 0;
     foreach ($this->form->getControls() as $control) {
         $control->setOption('rendered', FALSE);
     }
     if (strcasecmp($this->form->getMethod(), 'get') === 0) {
         $el = clone $this->form->getElementPrototype();
         $url = explode('?', (string) $el->action, 2);
         $el->action = $url[0];
         $s = '';
         if (isset($url[1])) {
             foreach (preg_split('#[;&]#', $url[1]) as $param) {
                 $parts = explode('=', $param, 2);
                 $name = urldecode($parts[0]);
                 if (!isset($this->form[$name])) {
                     $s .= Html::el('input', array('type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])));
                 }
             }
             $s = "\n\t" . $this->getWrapper('hidden container')->setHtml($s);
         }
         return $el->startTag() . $s;
     } else {
         return $this->form->getElementPrototype()->startTag();
     }
 }
 /**
  * Renders form end.
  * @return string
  */
 public static function renderFormEnd(Form $form)
 {
     $s = '';
     if (strcasecmp($form->getMethod(), 'get') === 0) {
         $url = explode('?', $form->getElementPrototype()->action, 2);
         if (isset($url[1])) {
             list($url[1]) = explode('#', $url[1], 2);
             foreach (preg_split('#[;&]#', $url[1]) as $param) {
                 $parts = explode('=', $param, 2);
                 $name = urldecode($parts[0]);
                 if (!isset($form[$name])) {
                     $s .= Nette\Utils\Html::el('input', array('type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])));
                 }
             }
         }
     }
     foreach ($form->getComponents(TRUE, 'Nette\\Forms\\Controls\\HiddenField') as $control) {
         if (!$control->getOption('rendered')) {
             $s .= $control->getControl();
         }
     }
     if (iterator_count($form->getComponents(TRUE, 'Nette\\Forms\\Controls\\TextInput')) < 2) {
         $s .= '<!--[if IE]><input type=IEbug disabled style="display:none"><![endif]-->';
     }
     echo ($s ? "<div>{$s}</div>\n" : '') . $form->getElementPrototype()->endTag() . "\n";
 }
Beispiel #3
0
 /**
  * Renders form end.
  * @return string
  */
 public static function renderFormEnd(Form $form, $withTags = TRUE)
 {
     $s = '';
     if (strcasecmp($form->getMethod(), 'get') === 0) {
         foreach (preg_split('#[;&]#', parse_url($form->getElementPrototype()->action, PHP_URL_QUERY), NULL, PREG_SPLIT_NO_EMPTY) as $param) {
             $parts = explode('=', $param, 2);
             $name = urldecode($parts[0]);
             if (!isset($form[$name])) {
                 $s .= Html::el('input', ['type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])]);
             }
         }
     }
     foreach ($form->getControls() as $control) {
         if ($control->getOption('type') === 'hidden' && !$control->getOption('rendered')) {
             $s .= $control->getControl();
         }
     }
     if (iterator_count($form->getComponents(TRUE, Nette\Forms\Controls\TextInput::class)) < 2) {
         $s .= "<!--[if IE]><input type=IEbug disabled style=\"display:none\"><![endif]-->\n";
     }
     return $s . ($withTags ? $form->getElementPrototype()->endTag() . "\n" : '');
 }
 /**
  * Renders form begin.
  * @return string
  */
 public function renderBegin()
 {
     $this->counter = 0;
     foreach ($this->form->getControls() as $control) {
         $control->setOption('rendered', FALSE);
     }
     if (strcasecmp($this->form->getMethod(), 'get') === 0) {
         $el = clone $this->form->getElementPrototype();
         $query = parse_url($el->action, PHP_URL_QUERY);
         $el->action = str_replace("?{$query}", '', $el->action);
         $s = '';
         foreach (preg_split('#[;&]#', $query, NULL, PREG_SPLIT_NO_EMPTY) as $param) {
             $parts = explode('=', $param, 2);
             $name = urldecode($parts[0]);
             if (!isset($this->form[$name])) {
                 $s .= Html::el('input', array('type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])));
             }
         }
         return $el->startTag() . ($s ? "\n\t" . $this->getWrapper('hidden container')->setHtml($s) : '');
     } else {
         return $this->form->getElementPrototype()->startTag();
     }
 }