Esempio n. 1
0
 function rendersInnerFieldWithValue()
 {
     M::stub($this->inside->render(Arg::any(), Arg::any()))->will()->forwardTo(function (Parameter $p, $v) {
         return $p->getName() . ':' . $v;
     });
     $this->assert->contains($this->field->render($this->param('foo'), 'bar'), 'checked="checked"/>' . "\n" . '<div id="foo-control">foo:bar</div>');
 }
Esempio n. 2
0
 function renderArrayWithItems()
 {
     Mockster::stub($this->mockster->render(Argument::any(), Argument::any()))->will()->forwardTo(function (Parameter $parameter, $value) {
         return '-- ' . $parameter->getName() . ': ' . $value . ' --';
     });
     $parameter = new Parameter('foo', new ArrayType(new StringType()));
     $rendered = $this->field->render($parameter, ['one', 'two']);
     $this->assert->contains($rendered, '<div class="array-item form-group input-group" style="width: 100%">' . "\n" . '<span class="sortable-handle input-group-addon"><span class="glyphicon glyphicon-sort"></span></span>' . "\n" . '-- foo[1]: one --');
     $this->assert->contains($rendered, '<div class="array-item form-group input-group" style="width: 100%">' . "\n" . '<span class="sortable-handle input-group-addon"><span class="glyphicon glyphicon-sort"></span></span>' . "\n" . '-- foo[2]: two --');
 }
Esempio n. 3
0
 private function makeInputGroup(WebField $field, Parameter $parameter, $id, $value = null)
 {
     return new Element('div', ['class' => 'array-item form-group input-group', 'style' => 'width: 100%'], [new Element('span', ['class' => 'sortable-handle input-group-addon'], [new Element('span', ['class' => 'glyphicon glyphicon-sort'])]), $field->render($parameter, $value), new Element('span', ['class' => 'input-group-btn'], [new Element('button', ['class' => 'btn btn-danger', 'onclick' => "\$(this).closest('.array-item').prependTo('#{$id}-new-items'); return false;"], ['X'])])]);
 }
Esempio n. 4
0
 function withValue()
 {
     $this->assert($this->field->render(new Parameter('foo', new StringType()), 'some stuff'), '<input class="form-control" type="text" name="foo" value="some stuff"/>');
 }
Esempio n. 5
0
 /**
  * @param Parameter $parameter
  * @param string $value
  * @return string
  */
 public function render(Parameter $parameter, $value)
 {
     $parameter = call_user_func($this->transformParameter, $parameter);
     $value = call_user_func($this->beforeRender, $value);
     return $this->field->render($parameter, $value);
 }
Esempio n. 6
0
 function withValue()
 {
     $this->assert($this->field->render(new Parameter('foo', new UnknownType()), 1234), '<input class="form-control" type="text" name="foo" value="1234"/>');
 }