Skip to content

Commit e600ea0

Browse files
authored
Ignore disabled fields' input
1 parent 73aca6a commit e600ea0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Kris/LaravelFormBuilder/Fields/FormField.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,18 @@ public function enable()
736736
return $this;
737737
}
738738

739+
/**
740+
* Whether this field is disabled.
741+
*
742+
* @return bool
743+
*/
744+
public function isDisabled()
745+
{
746+
$disabled = $this->getOption('attr.disabled');
747+
748+
return $disabled !== null && $disabled !== false;
749+
}
750+
739751
/**
740752
* Get validation rules for a field if any with label for attributes.
741753
*
@@ -775,7 +787,7 @@ public function getValidationRules()
775787
*/
776788
public function getAllAttributes()
777789
{
778-
return [$this->getNameKey()];
790+
return $this->isDisabled() ? [] : [$this->getNameKey()];
779791
}
780792

781793
/**

0 commit comments

Comments
 (0)