Exemplo n.º 1
0
 /**
  * @covers ::render
  * @group  Fieldset
  */
 public function testRenderWithElement()
 {
     $renderer = \Mockery::mock('Fuel\\Fieldset\\Render');
     $input = \Mockery::mock('Fuel\\Fieldset\\InputElement');
     $renderer->shouldReceive('render')->with($input)->once()->andReturn('<input/>');
     $this->object[] = $input;
     $this->assertXmlStringEqualsXmlFile($this->testFileLocations['testRenderWithElement'], $this->object->render($renderer));
 }
 /**
  * {@inheritdoc}
  */
 protected function createCreateForm()
 {
     $form = new Form();
     $form->setAttribute('method', 'POST');
     $form->setAttribute('action', $this->route);
     $customerFieldset = new Fieldset();
     $customerFieldset->setLegend(gettext('Customer details'));
     $customerFieldset['customerName'] = (new Input\Text('customerName'))->setLabel(gettext('Customer name'));
     $customerFieldset['customerPhone'] = (new Input\Text('customerPhone'))->setLabel(gettext('Customer phone'));
     $customerFieldset['customerEmail'] = (new Input\Email('customerEmail'))->setLabel(gettext('Customer email'));
     $form['customerDetails'] = $customerFieldset;
     $serviceFieldset = new Fieldset();
     $serviceFieldset->setLegend(gettext('Service details'));
     $serviceFieldset['description'] = (new Input\Textarea('description'))->setLabel(gettext('Description'));
     $serviceFieldset['estimatedEnd'] = (new Input\Text('estimatedEnd'))->setLabel(gettext('Estimated end'));
     $form['serviceDetails'] = $serviceFieldset;
     $form['submit'] = (new Input\Button('submit'))->setAttribute('type', 'submit')->setContents(gettext('Create'));
     return $form;
 }
Exemplo n.º 3
0
 /**
  * Adds a fieldset object to the table.
  *
  * @param  Fieldset $fieldset
  *
  * @since 2.0
  */
 public function renderFieldset(Fieldset $fieldset)
 {
     // Create a new renderer and render the content
     $fieldsetRenderer = new static($this->csrfProvider);
     // Generate all the content
     foreach ($fieldset as $item) {
         $fieldsetRenderer->render($item);
     }
     $content = $fieldsetRenderer->getRenderedForm();
     // Create the fieldset tag and add the content
     $tag = Html::tag('fieldset', $fieldset->getAttributes(), $content);
     // Make sure everything is added to the parent table
     $cell = new Table\Cell($tag);
     $cell->setAttributes(['colspan' => 2]);
     $this->table->addCell($cell);
     $this->table->addRow();
     return '';
 }