Exemplo n.º 1
0
 public function testHorizontalFormCreateFromConfig()
 {
     $this->Form->config(['align' => 'horizontal', 'templateSet' => ['horizontal' => ['checkboxFormGroup' => '<div class="%s"><div class="my-checkbox">{{label}}</div>{{error}}{{help}}</div>']]]);
     $result = $this->Form->create($this->article);
     $expected = ['form' => ['method' => 'post', 'accept-charset' => 'utf-8', 'role' => 'form', 'action' => '/articles/add', 'class' => 'form-horizontal'], 'div' => ['style' => 'display:none;'], 'input' => ['type' => 'hidden', 'name' => '_method', 'value' => 'POST'], '/div'];
     $this->assertHtml($expected, $result);
     $result = $this->Form->input('title');
     $expected = ['div' => ['class' => 'form-group text required'], 'label' => ['class' => 'control-label col-md-2', 'for' => 'title'], 'Title', '/label', ['div' => ['class' => 'col-md-6']], 'input' => ['type' => 'text', 'name' => 'title', 'id' => 'title', 'class' => 'form-control', 'required' => 'required'], '/div', '/div'];
     $this->assertHtml($expected, $result);
     $result = $this->Form->input('published');
     $expected = ['div' => ['class' => 'form-group checkbox'], ['div' => ['class' => 'col-md-offset-2 col-md-6']], ['div' => ['class' => 'my-checkbox']], 'input' => ['type' => 'hidden', 'name' => 'published', 'value' => 0], 'label' => ['for' => 'published'], ['input' => ['type' => 'checkbox', 'name' => 'published', 'id' => 'published', 'value' => 1]], 'Published', '/label', '/div', '/div', '/div'];
     $this->assertHtml($expected, $result);
 }