Example #1
0
 /**
  * @expectedException     Exception
  */
 public function testStartingWithElement()
 {
     $form = FluentForm::create();
     $fieldset = $form->containingFieldset();
     $fieldset->withLegend('legend');
     $fieldset->startingWithElement('p', 'A');
 }
 /**
  * @return \FewAgency\FluentForm\InputBlock
  */
 protected function getTestBlock()
 {
     $form = FluentForm::create();
     $form->idRegistrar(new \FewAgency\FluentHtml\HtmlIdRegistrar());
     return $form->containingInputBlock('test');
 }
Example #3
0
echo "\n\n";
// Form with options
echo FluentForm::create()->withAction('/login')->withMethod('DELETE')->withToken('12345');
echo "\n\n";
// Form with controls
echo FluentForm::create()->containingInputBlock('username')->withLabel('Your username')->followedByPasswordBlock()->withLabel('Your password');
echo "\n\n";
// Element with description
echo FluentForm::create()->containingInputBlock('name')->withDescription('Your full name');
echo "\n\n";
// Element with error message
echo FluentForm::create()->containingInputBlock('name')->withError('Must not contain numbers');
echo "\n\n";
// Checkboxes
echo FluentForm::create()->containingCheckboxBlock('toc')->required()->unchecked()->withCheckbox('other');
echo "\n\n";
// Select with optgroup, disabled and selected options
echo FluentForm::create()->containingSelectBlock('pet')->withSelectedOptions('dog')->withDisabledOptions('cat')->withOptions(['cat' => 'Cat', 'Reptiles' => ['turtle' => 'Turtle'], 'dog' => 'Dog']);
echo "\n\n";
// Buttons
echo FluentForm::create()->containingButtonBlock('Submit')->withButton('Reset', 'reset');
echo "\n\n";
// Adding maps to containers
FluentForm::create()->withSuccess('name', 'phone')->withRequired(['name' => true, 'phone' => false]);
echo "\n\n";
// Custom HTML next to input
echo FluentForm::create()->containingInputBlock('test')->getInputElement()->followedByElement('span', 'extra content')->getAncestorInstanceOf(\FewAgency\FluentForm\AbstractControlBlock::class)->followedByInputBlock('after');
echo "\n\n";
// Fieldset
echo FluentForm::create()->containingFieldset()->withLegend('A Group')->containingInputBlock('inside')->getControlBlockContainer()->followedByInputBlock('outside');
echo "\n\n";
Example #4
0
 /**
  * @return \FewAgency\FluentForm\InputBlock
  */
 protected function getTestBlock()
 {
     return FluentForm::create()->containingCheckboxBlock('test');
 }
Example #5
0
 /**
  * @return FluentForm
  */
 protected function getTestForm()
 {
     $form = FluentForm::create();
     $form->idRegistrar(new \FewAgency\FluentHtml\HtmlIdRegistrar());
     return $form;
 }
Example #6
0
 /**
  * @return \FewAgency\FluentForm\ButtonBlock
  */
 protected function getTestBlock()
 {
     return FluentForm::create()->containingButtonBlock('A');
 }
 /**
  * @return \FewAgency\FluentForm\SelectBlock
  */
 protected function getTestBlock()
 {
     $f = FluentForm::create();
     $f->idRegistrar(new \FewAgency\FluentHtml\HtmlIdRegistrar());
     return $f->containingMultiSelectBlock('A');
 }
Example #8
0
 /**
  * @return \FewAgency\FluentForm\InputBlock
  */
 protected function getTestBlock()
 {
     return FluentForm::create()->containingInputBlock('test', 'textarea');
 }
Example #9
0
 /**
  * @return \FewAgency\FluentForm\InputBlock
  */
 protected function getTestBlock()
 {
     return FluentForm::create()->containingPasswordBlock('test');
 }
 public function testWithRequired()
 {
     $form = FluentForm::create();
     $fieldset = $form->containingFieldset();
     $form->withRequired('form');
     $this->assertTrue($fieldset->isRequired('form'));
     $fieldset->withRequired(['fieldset' => true, 'form' => false]);
     $this->assertTrue($fieldset->isRequired('fieldset'));
     $this->assertFalse($fieldset->isRequired('form'));
 }