From 9f659241e3cd276b3e71a1d2c495334028c67dcf Mon Sep 17 00:00:00 2001 From: Philippe Lonchampt Date: Wed, 13 Jan 2016 09:51:45 +0100 Subject: [PATCH] Add missing form fields config --- .../FormFields/SharpHiddenFormFieldConfig.php | 27 +++++++ .../SharpPasswordFormFieldConfig.php | 27 +++++++ .../SharpRefSublistItemFormFieldConfig.php | 73 +++++++++++++++++++ src/Dvlpp/Sharp/Form/Fields/HiddenField.php | 4 +- src/Dvlpp/Sharp/Form/Fields/PasswordField.php | 4 +- .../Sharp/Form/Fields/RefSublistItemField.php | 13 ++-- src/Dvlpp/Sharp/Form/Fields/TextField.php | 4 +- 7 files changed, 144 insertions(+), 8 deletions(-) create mode 100644 src/Dvlpp/Sharp/Config/FormFields/SharpHiddenFormFieldConfig.php create mode 100644 src/Dvlpp/Sharp/Config/FormFields/SharpPasswordFormFieldConfig.php create mode 100644 src/Dvlpp/Sharp/Config/FormFields/SharpRefSublistItemFormFieldConfig.php diff --git a/src/Dvlpp/Sharp/Config/FormFields/SharpHiddenFormFieldConfig.php b/src/Dvlpp/Sharp/Config/FormFields/SharpHiddenFormFieldConfig.php new file mode 100644 index 0000000..47c59e9 --- /dev/null +++ b/src/Dvlpp/Sharp/Config/FormFields/SharpHiddenFormFieldConfig.php @@ -0,0 +1,27 @@ +key = $key; + + $instance->label = ""; + + return $instance; + } + + public function type() + { + return "hidden"; + } +} \ No newline at end of file diff --git a/src/Dvlpp/Sharp/Config/FormFields/SharpPasswordFormFieldConfig.php b/src/Dvlpp/Sharp/Config/FormFields/SharpPasswordFormFieldConfig.php new file mode 100644 index 0000000..b19da91 --- /dev/null +++ b/src/Dvlpp/Sharp/Config/FormFields/SharpPasswordFormFieldConfig.php @@ -0,0 +1,27 @@ +key = $key; + + $instance->label = ""; + + return $instance; + } + + public function type() + { + return "password"; + } +} \ No newline at end of file diff --git a/src/Dvlpp/Sharp/Config/FormFields/SharpRefSublistItemFormFieldConfig.php b/src/Dvlpp/Sharp/Config/FormFields/SharpRefSublistItemFormFieldConfig.php new file mode 100644 index 0000000..6bc8868 --- /dev/null +++ b/src/Dvlpp/Sharp/Config/FormFields/SharpRefSublistItemFormFieldConfig.php @@ -0,0 +1,73 @@ +key = $key; + $instance->repository = $repository; + $instance->linkedRefField = $linkedRefField; + $instance->refListKey = $refListKey; + + $instance->label = ""; + + return $instance; + } + + public function type() + { + return "ref"; + } + + /** + * @return string + */ + public function repository() + { + return $this->repository; + } + + /** + * @return string + */ + public function linkedRefField() + { + return $this->linkedRefField; + } + + /** + * @return string + */ + public function refListKey() + { + return $this->refListKey; + } + +} \ No newline at end of file diff --git a/src/Dvlpp/Sharp/Form/Fields/HiddenField.php b/src/Dvlpp/Sharp/Form/Fields/HiddenField.php index ac9a24a..177142f 100644 --- a/src/Dvlpp/Sharp/Form/Fields/HiddenField.php +++ b/src/Dvlpp/Sharp/Form/Fields/HiddenField.php @@ -1,4 +1,6 @@ -_checkMandatoryAttributes(["repository","linked_ref_field","ref_list_id"]); + $this->_checkMandatoryAttributes(["repository","linkedRefField","refListKey"]); + + $repoName = $this->field->repository(); - $repoName = $this->field->repository; if(class_exists($repoName) || interface_exists($repoName)) { $repo = app($repoName); $this->addClass("sharp-refSublistItem", true); - $this->addData("linked_ref_field", $this->field->linked_ref_field); + $this->addData("linked_ref_field", $this->field->linkedRefField()); if(method_exists($repo, "formListForSublist")) { - $allValues = $repo->formListForSublist($this->field->ref_list_id, $this->instance); + $allValues = $repo->formListForSublist($this->field->refListKey(), $this->instance); // We have to manually handle the initial value, in JS code, // because of linked selects diff --git a/src/Dvlpp/Sharp/Form/Fields/TextField.php b/src/Dvlpp/Sharp/Form/Fields/TextField.php index efa0779..6f8c8f1 100644 --- a/src/Dvlpp/Sharp/Form/Fields/TextField.php +++ b/src/Dvlpp/Sharp/Form/Fields/TextField.php @@ -1,4 +1,6 @@ -