/** * Generates the opening of a form and wraps it. * * @param string $url The url to send the action to * @param string $method The header request method to send the form (i.e. : GET,POST) * @param string[] $opts Contains the option="value" key-value pairs to be added to the form * * @return string The wrapped HTML form */ public function open($url, $method, $opts = []) { $realMethod = $method; if ($realMethod != 'get') { $realMethod = 'post'; } if (!array_key_exists('class', $opts)) { $opts['class'] = 'form-horizontal'; } $html = "<form action=\"{$url}\" method=\"{$realMethod}\""; $control = new Text(); $html .= $control->getOpts($opts); $html .= '>'; if ($method != 'get' && $method != 'post') { $html .= '<input type="hidden" name="_method" value="' . $method . '" />' . "\n"; } return $html; }
public function testTextPrepare() { $text = new Text(); $this->assertEquals($text->prepare(['test', ['class' => 'toaster'], 'default']), '<input type="text" name="test" value="default" class="toaster"/>'); }