Example #1
0
 public function testFormAttributes()
 {
     $this->assertEquals(Form::METHOD_POST, $this->object->getMethod());
     $this->object->setMethod(Form::METHOD_GET);
     $this->assertEquals(Form::METHOD_GET, $this->object->getMethod());
     $this->assertEquals(null, $this->object->getAction());
     $this->object->setAction('/some/url');
     $this->assertEquals('/some/url', $this->object->getAction());
     $this->assertFalse($this->object->isMultipart());
     $this->object->setMultipart(true);
     $this->assertTrue($this->object->isMultipart());
     $this->assertInstanceOf('\\ArrayIterator', $this->object->getIterator());
 }
Example #2
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();
         $uri = explode('?', (string) $el->action, 2);
         $el->action = $uri[0];
         $s = '';
         if (isset($uri[1])) {
             foreach (preg_split('#[;&]#', $uri[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();
     }
 }
Example #3
0
 /**
  * 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])) {
             foreach (preg_split('#[;&]#', $url[1]) as $param) {
                 $parts = explode('=', $param, 2);
                 $name = urldecode($parts[0]);
                 if (!isset($form[$name])) {
                     $s .= Html::el('input', array('type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])));
                 }
             }
         }
     }
     foreach ($form->getComponents(TRUE, 'HiddenField') as $control) {
         if (!$control->getOption('rendered')) {
             $s .= $control->getControl();
         }
     }
     if (iterator_count($form->getComponents(TRUE, 'TextInput')) < 2) {
         $s .= '<!--[if IE]><input type=IEbug disabled style="display:none"><![endif]-->';
     }
     echo ($s ? "<div>{$s}</div>\n" : '') . $form->getElementPrototype()->endTag() . "\n";
 }
Example #4
0
 /**
  * @covers Xoops\Form\Form::getMethod
  */
 public function testGetMethod()
 {
     $value = $this->object->getMethod();
     $this->assertSame('post', $value);
 }