public function testFromArrayNull() { $mock = new MockLayout(); $form = Form::fromArray('id', null, function ($f) { $f->textField('foo', 'Label'); }, ['layout' => $mock]); $this->assertArrayHasKey('foo', $mock->field); $this->assertEquals(false, $mock->field['foo']->attribute('value')); }
<?php /*~*/ use NitroXy\PHPForms\Form; global $layout; $data = []; Form::fromArray('checkboxes', $data, function ($f) { $f->checkbox('a', 'Text 1', null, ['hint' => 'Checkbox using regular label']); $f->checkbox('b', 'Text 2', false, ['hint' => 'Checkbox using inline label']); $f->group('Label', function ($f) { $f->checkbox('c', 'Text 3'); $f->checkbox('d', 'Text 4'); }, ['hint' => 'Checkbox using group']); }, ['layout' => $layout]);
<?php /*~*/ use NitroXy\PHPForms\Form; global $layout; $data = ['a' => '1', 'e' => '2', 'i' => '3']; Form::fromArray('example5', $data, function ($f) { $f->textarea('foo', 'Regular textarea', ['hint' => 'Lorem ipsum']); $f->textarea('bar', '"tworow"', ['tworow' => true, 'hint' => 'Lorem ipsum']); $f->textarea('baz', '"tworow" + "fill"', ['tworow' => true, 'fill' => true, 'hint' => 'Lorem ipsum']); }, ['layout' => $layout]);
<?php /*~*/ use NitroXy\PHPForms\Form; global $layout; $data = ['a' => 'Value 1', 'b' => 'Value 2', 'c' => 'Value 3', 'd' => 'Value 4']; Form::fromArray('example_prefix_suffix', $data, function ($f) { $f->textField('a', 'Text 1'); $f->textField('b', 'Text 2', ['prefix' => 'Prefix']); $f->textField('c', 'Text 3', ['suffix' => 'Suffix']); $f->textField('d', 'Text 4', ['prefix' => 'Prefix', 'suffix' => 'Suffix']); }, ['layout' => $layout]);
<?php /*~*/ use NitroXy\PHPForms\Form; global $layout; $data = ['a' => 'Value 1', 'b' => 'Value 2', 'c' => 'Value 3']; Form::fromArray('example5', $data, function ($f) { $f->textField('a', 'Text 1'); $f->textField('b', 'Text 2'); $f->textField('c', 'Text 3', ['required' => true, 'hint' => 'Required field']); }, ['layout' => $layout]);
<?php /*~*/ use NitroXy\PHPForms\Form; global $layout; $data = ['a' => '1', 'e' => '2', 'i' => '3']; Form::fromArray('example5', $data, function ($f) { $f->group('Row 1', function ($f) { $f->textField('a', 'Text 1', ['style' => 'width: 50px;']); $f->textField('b', 'Text 2', ['style' => 'width: 50px;']); $f->textField('c', 'Text 3', ['style' => 'width: 50px;']); }); $f->group('Row 2', function ($f) { $f->textField('d', 'Text 1', ['style' => 'width: 50px;']); $f->textField('e', 'Text 2', ['style' => 'width: 50px;']); $f->textField('f', 'Text 3', ['style' => 'width: 50px;']); }); $f->group('Row 3', function ($f) { $f->textField('g', 'Text 1', ['style' => 'width: 50px;']); $f->textField('h', 'Text 2', ['style' => 'width: 50px;']); $f->textField('i', 'Text 3', ['style' => 'width: 50px;']); }); $f->group(false, function ($f) { $f->button('Action 1'); $f->button('Action 2'); }); }, ['layout' => $layout]);
<?php /*~*/ use NitroXy\PHPForms\Form; global $layout; $data = ['a' => 'Value 1', 'b' => 'Value 2', 'c' => 'Value 3', 'd' => 'Value 4', 'e' => 'Value 5']; Form::fromArray('example5', $data, function ($f) { $f->textField('a', 'Text 1'); $f->fieldset('Fieldset A', function ($f) { $f->textField('b', 'Text 2'); $f->textField('c', 'Text 3'); }); $f->fieldset('Fieldset B', function ($f) { $f->textField('d', 'Text 4'); $f->textField('e', 'Text 5'); }); }, ['layout' => $layout]);
<?php /*~*/ use NitroXy\PHPForms\Form; global $layout; $data = ['a' => '1', 'd' => '2', 'g' => '3']; Form::fromArray('example5', $data, function ($f) { $f->group('Row 1', function ($f) { $f->textField('a', 'Text 1'); $f->textField('b', 'Text 2'); $f->textField('c', 'Text 3'); }); $f->group('Row 2', function ($f) { $f->textField('d', 'Text 1', ['class' => 'col-xs-8']); $f->textField('e', 'Text 2', ['class' => 'col-xs-4']); }); $f->group('Row 3', function ($f) { $f->textField('f', 'Text 1', ['class' => 'col-xs-4']); $f->textField('g', 'Text 2', ['class' => 'col-xs-8']); }); $f->group(false, function ($f) { $f->button('Action 1'); $f->button('Action 2'); }); }, ['layout' => $layout]);
<?php /*~*/ use NitroXy\PHPForms\Form; global $layout; $data = ['a' => '1', 'e' => '2', 'i' => '3']; Form::fromArray('example5', $data, function ($f) { $f->hint('Row-level hints offers a hint that spans an entire row (similar to a paragraph).', false); $f->hint('Field-level hints has a similar look as a static field.', 'Field'); $f->textField('a', 'Text 1', ['hint' => 'Field hints describe a specific field']); }, ['layout' => $layout]);