Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit 13212f9

Browse files
committed
Avoid duplication of passing help block enabled (or not) in closeGroup
1 parent 95e5237 commit 13212f9

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/Manavo/BootstrapForms/FormBuilder.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ class FormBuilder extends IlluminateFormBuilder
1414
*/
1515
protected $groupStack = [];
1616

17+
/**
18+
* An array containing the options of the currently open form groups.
19+
*
20+
* @var array
21+
*/
22+
protected $groupOptions = [];
23+
1724
/**
1825
* Open a new form group.
1926
*
@@ -35,6 +42,8 @@ public function openGroup(
3542
// Append the name of the group to the groupStack.
3643
$this->groupStack[] = $name;
3744

45+
$this->groupOptions[] = $options;
46+
3847
// Check to see if error blocks are enabled
3948
if ($this->errorBlockEnabled($options)) {
4049
if ($this->hasErrors($name)) {
@@ -54,18 +63,20 @@ public function openGroup(
5463
/**
5564
* Close out the last opened form group.
5665
*
57-
* @param bool $helpBlock - determines whether the formatted field errors should be displayed
58-
*
5966
* @return string
6067
*/
61-
public function closeGroup($helpBlock = true)
68+
public function closeGroup()
6269
{
6370
// Get the last added name from the groupStack and
6471
// remove it from the array.
6572
$name = array_pop($this->groupStack);
6673

74+
// Get the last added options to the groupOptions
75+
// This way we can check if error blocks were enabled
76+
$options = array_pop($this->groupOptions);
77+
6778
// Check to see if we are to include the formatted help block
68-
if ($helpBlock) {
79+
if ($this->errorBlockEnabled($options)) {
6980
// Get the formatted errors for this form group.
7081
$errors = $this->getFormattedErrors($name);
7182
}

0 commit comments

Comments
 (0)