Skip to content

Commit

Permalink
because of new setUp method
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Sep 19, 2024
1 parent 3228b65 commit ef7bf44
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Forms/BaseForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function make()
}

$this->html = $this->open($options);

$this->setUp();
$fields = $this->parseFields($this->fields());
$this->builder->setSections($this->setSections($fields));

Expand Down
11 changes: 11 additions & 0 deletions src/Forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ public function config()
// Return nothing please.
}

/**
* This function returns nothing and is meant
* for setting up details of the form
*
* @return void
*/
public function setUp()
{
// Return nothing please.
}

/**
* Generate a button form based on method and route
*
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/LivewireForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function make($data = [])
];

$this->html = $this->open($options);

$this->setUp();
$fields = $this->parseFields($this->fields());
$this->builder->setSections($this->setSections($fields));

Expand Down
2 changes: 1 addition & 1 deletion src/Forms/ModalForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function make()
}

$this->html = $this->open($options);

$this->setUp();
$fields = $this->parseFields($this->fields());
$this->builder->setSections($this->setSections($fields));

Expand Down
4 changes: 2 additions & 2 deletions src/Forms/ModelForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function create()
}

$this->html = $this->open($options);

$this->setUp();
$fields = $this->parseFields($this->fields());
$this->builder->setSections($this->setSections($fields));

Expand Down Expand Up @@ -260,7 +260,7 @@ public function edit($model = null)
}

$this->html = $this->model($this->instance, $options);

$this->setUp();
$fields = $this->parseFields($this->fields());
$this->builder->setSections($this->setSections($fields));

Expand Down
2 changes: 1 addition & 1 deletion src/Forms/WizardForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function make()
}

$this->html = $this->open($options);

$this->setUp();
$fields = $this->parseFields($this->fields());
$this->builder->setSteps($this->steps($fields));
$this->fieldsForSteps = $fields;
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/FormBaseTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Tests\Unit;

use Tests\TestCase;
Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/FormExtensiveBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class UserSampleCreateForm extends BaseForm

public $orientation = 'horizontal';

public function setUp()
{
$this->buttons['submit'] = 'DO NOT CLICK!';
}

public function fields()
{
return [
Expand Down Expand Up @@ -112,11 +117,13 @@ public function testMakeWithClassChanges()

$this->assertStringContainsString('http://localhost/user/sample', $form);
$this->assertStringContainsString('method="POST"', $form);
$this->assertStringContainsString('DO NOT CLICK!', $form);

$this->assertStringContainsString('<form method="POST" action="http://localhost/user/sample" accept-charset="UTF-8" class="batman-horizontal" id="batman">', $form);
$this->assertStringContainsString('<div class="form-group row"><label class="col-md-2 col-form-label pt-0" for="Name">Name</label>', $form);
$this->assertStringContainsString('<div class="col-md-10"><input class="form-control" id="Name" name="name" type="text" value="">', $form);
$this->assertStringContainsString('<legend class="col-md-2 col-form-label pt-0"></legend><div class="col-md-10"><div class="form-check">', $form);
$this->assertStringContainsString('<input class="form-check-input batman-style" id="Is_cool" type="checkbox" name="is_cool"><label class="form-check-label" for="Is_cool">Is Cool</label>', $form);

}
}

0 comments on commit ef7bf44

Please sign in to comment.