Exemple #1
0
 function requireHeadElementsOfInnerField()
 {
     M::stub($this->inside->headElements(Arg::any()))->will()->return_([new Element('link', ['src' => 'foo.bar']), new Element('link', ['src' => 'bar.bas'])]);
     $headElements = implode('', $this->field->headElements($this->param('foo')));
     $this->assert->contains($headElements, (string) HeadElements::jquery());
     $this->assert->contains($headElements, 'src="foo.bar"');
     $this->assert->contains($headElements, 'src="bar.bas"');
 }
Exemple #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 --');
 }
Exemple #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'])])]);
 }
Exemple #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"/>');
 }
Exemple #5
0
 /**
  * @param Parameter $parameter
  * @return array|Element[]
  */
 public function headElements(Parameter $parameter)
 {
     $parameter = call_user_func($this->transformParameter, $parameter);
     $elements = $this->field->headElements($parameter);
     return call_user_func($this->afterHeadElements, $elements);
 }
Exemple #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"/>');
 }