diff --git a/src/Form.php b/src/Form.php index 9e03745..0437710 100644 --- a/src/Form.php +++ b/src/Form.php @@ -58,6 +58,14 @@ class Form */ protected $formConfig = []; + /** + * Form configuration name. + * + * @var array + */ + protected $formConfigName = null; + + /** * Additional data which can be used to build fields. * @@ -542,7 +550,7 @@ public function setFormOption($option, $value) */ public function getConfig($key = null, $default = null) { - return $this->formHelper->getConfig($key, $default, $this->formConfig); + return $this->formHelper->getConfig($key, $default, $this->formConfig, $this->formConfigName); } /** diff --git a/src/FormBuilderServiceProvider.php b/src/FormBuilderServiceProvider.php index de44712..79c0919 100644 --- a/src/FormBuilderServiceProvider.php +++ b/src/FormBuilderServiceProvider.php @@ -77,7 +77,7 @@ protected function registerFormHelper() $formHelperClass = $this->getFormHelperClass(); $this->app->singleton($abstract, function ($app) use ($formHelperClass) { - $configuration = $app->make(ConfigFactory::class)->formConfig(); + $configuration = $app->make(ConfigFactory::class); return new $formHelperClass($app['view'], $app['translator'], $configuration); }); diff --git a/src/FormHelper.php b/src/FormHelper.php index 0a366a3..71725f7 100644 --- a/src/FormHelper.php +++ b/src/FormHelper.php @@ -87,11 +87,11 @@ class FormHelper */ private $customTypes = []; - public function __construct(View $view, Translator $translator, array $config = []) + public function __construct(View $view, Translator $translator, ConfigFactory $configFactory) { $this->view = $view; $this->translator = $translator; - $this->config = $config; + $this->config = $configFactory; $this->loadCustomTypes(); } @@ -101,9 +101,9 @@ public function __construct(View $view, Translator $translator, array $config = * @param array $customConfig * @return mixed */ - public function getConfig($key = null, $default = null, $customConfig = []) + public function getConfig($key = null, $default = null, $customConfig = [], ?string $form = null) { - $config = array_replace_recursive($this->config, $customConfig); + $config = array_replace_recursive($this->config->formConfig($form), $customConfig); if ($key) { return Arr::get($config, $key, $default);