Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Jan 8, 2024
2 parents 4b3fd45 + ca7d9ce commit 3a1527c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/Field/AbstractField.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ManageLabelTrait,
ManageRenderTrait,
ManageWrapperTrait};
use Windwalker\Form\Attributes\Fieldset;
use Windwalker\Form\Form;
use Windwalker\Form\FormNormalizer;
use Windwalker\Form\FormRegistry;
Expand Down Expand Up @@ -342,12 +343,16 @@ public function getFieldset(): ?string
/**
* Method to set property fieldset
*
* @param ?string $fieldset
* @param Fieldset|string|null $fieldset
*
* @return static Return self to support chaining.
*/
public function setFieldset(?string $fieldset): static
public function setFieldset(Fieldset|string|null $fieldset): static
{
if ($fieldset instanceof Fieldset) {
$fieldset = $fieldset->getName();
}

$this->fieldset = $fieldset;

return $this;
Expand Down
8 changes: 3 additions & 5 deletions src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,12 @@ public function addField(
Fieldset|string|null $fieldset = null,
string $namespace = ''
): AbstractField {
if ($fieldset) {
$fieldset = $this->fieldset($fieldset);
} else {
if ($fieldset === null) {
$fieldset = $this->fieldset;
}

if ($fieldset) {
$field->setFieldset($fieldset->getName());
if ($fieldset !== null) {
$field->setFieldset($fieldset);
}

if (!$namespace) {
Expand Down

0 comments on commit 3a1527c

Please sign in to comment.