aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/sprinkles/FormGenerator/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/app/sprinkles/FormGenerator/src')
-rw-r--r--main/app/sprinkles/FormGenerator/src/Controller/FormGeneratorController.php4
-rw-r--r--main/app/sprinkles/FormGenerator/src/Element/Alert.php7
-rw-r--r--main/app/sprinkles/FormGenerator/src/Element/BaseInput.php12
-rw-r--r--main/app/sprinkles/FormGenerator/src/Element/Checkbox.php11
-rw-r--r--main/app/sprinkles/FormGenerator/src/Element/Hidden.php7
-rw-r--r--main/app/sprinkles/FormGenerator/src/Element/InputInterface.php7
-rw-r--r--main/app/sprinkles/FormGenerator/src/Element/Select.php7
-rw-r--r--main/app/sprinkles/FormGenerator/src/Element/Text.php7
-rw-r--r--main/app/sprinkles/FormGenerator/src/Element/Textarea.php7
-rw-r--r--main/app/sprinkles/FormGenerator/src/Form.php40
10 files changed, 57 insertions, 52 deletions
diff --git a/main/app/sprinkles/FormGenerator/src/Controller/FormGeneratorController.php b/main/app/sprinkles/FormGenerator/src/Controller/FormGeneratorController.php
index e731011..5bd46e1 100644
--- a/main/app/sprinkles/FormGenerator/src/Controller/FormGeneratorController.php
+++ b/main/app/sprinkles/FormGenerator/src/Controller/FormGeneratorController.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator\Controller;
use UserFrosting\Sprinkle\Core\Controller\SimpleController;
@@ -15,7 +16,8 @@ use UserFrosting\Sprinkle\Core\Controller\SimpleController;
*
* Controller class for /forms/confirm/* URLs. Handles rendering the confirm dialog
*/
-class FormGeneratorController extends SimpleController {
+class FormGeneratorController extends SimpleController
+{
/**
* Display the confirmation dialog
diff --git a/main/app/sprinkles/FormGenerator/src/Element/Alert.php b/main/app/sprinkles/FormGenerator/src/Element/Alert.php
index f848b5c..31453d3 100644
--- a/main/app/sprinkles/FormGenerator/src/Element/Alert.php
+++ b/main/app/sprinkles/FormGenerator/src/Element/Alert.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator\Element;
use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
@@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
*
* @extends BaseInput
*/
-class Alert extends BaseInput {
+class Alert extends BaseInput
+{
/**
* {@inheritDoc}
*/
- protected function applyTransformations()
- {
+ protected function applyTransformations() {
$this->element = array_merge([
"class" => "alert-danger",
"icon" => "fa-ban",
diff --git a/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php b/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php
index d892001..cf78dc6 100644
--- a/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php
+++ b/main/app/sprinkles/FormGenerator/src/Element/BaseInput.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator\Element;
use UserFrosting\Sprinkle\FormGenerator\Element\InputInterface;
@@ -20,7 +21,8 @@ use UserFrosting\Sprinkle\Core\Facades\Debug;
* @abstract
* @implements InputInterface
*/
-abstract class BaseInput implements InputInterface {
+abstract class BaseInput implements InputInterface
+{
/**
* @var String The name of the input.
@@ -46,8 +48,7 @@ abstract class BaseInput implements InputInterface {
* @param mixed $value (default: null)
* @return void
*/
- public function __construct($name, $element, $value = null)
- {
+ public function __construct($name, $element, $value = NULL) {
$this->name = $name;
$this->element = $element;
$this->value = $value;
@@ -60,8 +61,7 @@ abstract class BaseInput implements InputInterface {
* @access public
* @return void
*/
- public function parse()
- {
+ public function parse() {
$this->applyTransformations();
return $this->element;
}
@@ -89,7 +89,7 @@ abstract class BaseInput implements InputInterface {
* @return string The input current value
*/
public function getValue() {
- if (isset($this->value) && $this->value !== null) {
+ if (isset($this->value) && $this->value !== NULL) {
return $this->value;
} else if (isset($this->element['default'])) {
return $this->element['default'];
diff --git a/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php b/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php
index 59e6eaf..97bfdba 100644
--- a/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php
+++ b/main/app/sprinkles/FormGenerator/src/Element/Checkbox.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator\Element;
use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
@@ -16,22 +17,22 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
*
* @extends BaseInput
*/
-class Checkbox extends BaseInput {
+class Checkbox extends BaseInput
+{
/**
* {@inheritDoc}
*/
- protected function applyTransformations()
- {
+ protected function applyTransformations() {
$this->element = array_merge([
"class" => "js-icheck",
"name" => $this->name,
"id" => "field_" . $this->name,
- "binary" => true
+ "binary" => TRUE
], $this->element);
// We add the check status instead of the value
- if ($this->element["binary"] !== false && $this->getValue() == 1) {
+ if ($this->element["binary"] !== FALSE && $this->getValue() == 1) {
$this->element["checked"] = "checked";
}
}
diff --git a/main/app/sprinkles/FormGenerator/src/Element/Hidden.php b/main/app/sprinkles/FormGenerator/src/Element/Hidden.php
index 08c22f7..6f79ecd 100644
--- a/main/app/sprinkles/FormGenerator/src/Element/Hidden.php
+++ b/main/app/sprinkles/FormGenerator/src/Element/Hidden.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator\Element;
use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
@@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
*
* @extends BaseInput
*/
-class Hidden extends BaseInput {
+class Hidden extends BaseInput
+{
/**
* {@inheritDoc}
*/
- protected function applyTransformations()
- {
+ protected function applyTransformations() {
$this->element = array_merge([
"value" => $this->getValue(),
"name" => $this->name,
diff --git a/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php b/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php
index 7405109..66225bc 100644
--- a/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php
+++ b/main/app/sprinkles/FormGenerator/src/Element/InputInterface.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator\Element;
/**
@@ -13,7 +14,9 @@ namespace UserFrosting\Sprinkle\FormGenerator\Element;
*
* Interface for Form elements classes
*/
-interface InputInterface {
- public function __construct($name, $element, $value = null);
+interface InputInterface
+{
+ public function __construct($name, $element, $value = NULL);
+
public function parse();
}
diff --git a/main/app/sprinkles/FormGenerator/src/Element/Select.php b/main/app/sprinkles/FormGenerator/src/Element/Select.php
index bb23772..da91fbd 100644
--- a/main/app/sprinkles/FormGenerator/src/Element/Select.php
+++ b/main/app/sprinkles/FormGenerator/src/Element/Select.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator\Element;
use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
@@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
*
* @extends BaseInput
*/
-class Select extends BaseInput {
+class Select extends BaseInput
+{
/**
* {@inheritDoc}
*/
- protected function applyTransformations()
- {
+ protected function applyTransformations() {
$this->element = array_merge([
"class" => "form-control js-select2",
"value" => $this->getValue(),
diff --git a/main/app/sprinkles/FormGenerator/src/Element/Text.php b/main/app/sprinkles/FormGenerator/src/Element/Text.php
index b936fe2..375153d 100644
--- a/main/app/sprinkles/FormGenerator/src/Element/Text.php
+++ b/main/app/sprinkles/FormGenerator/src/Element/Text.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator\Element;
use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
@@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
*
* @extends BaseInput
*/
-class Text extends BaseInput {
+class Text extends BaseInput
+{
/**
* {@inheritDoc}
*/
- protected function applyTransformations()
- {
+ protected function applyTransformations() {
$this->element = array_merge([
"autocomplete" => "off",
"class" => "form-control",
diff --git a/main/app/sprinkles/FormGenerator/src/Element/Textarea.php b/main/app/sprinkles/FormGenerator/src/Element/Textarea.php
index bec3a6c..b2a84f9 100644
--- a/main/app/sprinkles/FormGenerator/src/Element/Textarea.php
+++ b/main/app/sprinkles/FormGenerator/src/Element/Textarea.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator\Element;
use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
@@ -16,13 +17,13 @@ use UserFrosting\Sprinkle\FormGenerator\Element\BaseInput;
*
* @extends BaseInput
*/
-class Textarea extends BaseInput {
+class Textarea extends BaseInput
+{
/**
* {@inheritDoc}
*/
- protected function applyTransformations()
- {
+ protected function applyTransformations() {
$this->element = array_merge([
"autocomplete" => "off",
"class" => "form-control",
diff --git a/main/app/sprinkles/FormGenerator/src/Form.php b/main/app/sprinkles/FormGenerator/src/Form.php
index e845e3e..5b948f7 100644
--- a/main/app/sprinkles/FormGenerator/src/Form.php
+++ b/main/app/sprinkles/FormGenerator/src/Form.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Sprinkle\FormGenerator;
use Illuminate\Contracts\Config\Repository;
@@ -20,7 +21,8 @@ use UserFrosting\Fortress\RequestSchema\RequestSchemaInterface;
* The FormGenerator class, which is used to return the `form` part from a Fortress
* schema for html form generator in Twig.
*/
-class Form {
+class Form
+{
/**
* @var RequestSchemaInterface The form fields definition
@@ -44,8 +46,7 @@ class Form {
* @param array|object $data (default: [])
* @return void
*/
- public function __construct(RequestSchemaInterface $schema, $data = [])
- {
+ public function __construct(RequestSchemaInterface $schema, $data = []) {
$this->setSchema($schema);
$this->setData($data);
}
@@ -55,8 +56,7 @@ class Form {
*
* @param array|object $data The form values
*/
- public function setData($data)
- {
+ public function setData($data) {
if ($data instanceof Collection || $data instanceof Model) {
$this->data = $data->toArray();
} else if (is_array($data) || $data instanceof Repository) {
@@ -71,8 +71,7 @@ class Form {
*
* @param RequestSchemaInterface $schema A RequestSchemaInterface object, containing the form definition.
*/
- public function setSchema(RequestSchemaInterface $schema)
- {
+ public function setSchema(RequestSchemaInterface $schema) {
$this->schema = $schema;
}
@@ -83,8 +82,7 @@ class Form {
* @param mixed $value
* @return void
*/
- public function setValue($inputName, $value)
- {
+ public function setValue($inputName, $value) {
$this->data[$inputName] = $value;
}
@@ -94,12 +92,11 @@ class Form {
* Use `setCustomFormData` to set any other tag.
*
* @param string $inputName The input name where the argument will be added
- * @param string $property The argument name. Example "data-color"
- * @param string $data The value of the argument
+ * @param string $property The argument name. Example "data-color"
+ * @param string $data The value of the argument
* @return void
*/
- public function setInputArgument($inputName, $property, $data)
- {
+ public function setInputArgument($inputName, $property, $data) {
if ($this->schema->has($inputName)) {
// Get the element and force set the property
$element = $this->schema->get($inputName);
@@ -115,12 +112,11 @@ class Form {
* `setInputArgument` and `setValue`.
*
* @param string $inputName The select name to add options to
- * @param array $data An array of `value => label` options
- * @param string $selected The selected key
+ * @param array $data An array of `value => label` options
+ * @param string $selected The selected key
* @return void
*/
- public function setOptions($inputName, $data = [], $selected = null)
- {
+ public function setOptions($inputName, $data = [], $selected = NULL) {
// Set opdations
$this->setInputArgument($inputName, 'options', $data);
@@ -139,8 +135,7 @@ class Form {
* @param string $namespace
* @return void
*/
- public function setFormNamespace($namespace)
- {
+ public function setFormNamespace($namespace) {
$this->formNamespace = $namespace;
}
@@ -150,8 +145,7 @@ class Form {
*
* @return array The form fields data
*/
- public function generate()
- {
+ public function generate() {
$form = collect([]);
// Loop all the the fields in the schema
@@ -161,10 +155,10 @@ class Form {
if (isset($input['form'])) {
// Get the value from the data
- $value = isset($this->data[$name]) ? $this->data[$name] : null;
+ $value = isset($this->data[$name]) ? $this->data[$name] : NULL;
// Add the namespace to the name if it's defined
- $name = ($this->formNamespace != "") ? $this->formNamespace."[".$name."]" : $name;
+ $name = ($this->formNamespace != "") ? $this->formNamespace . "[" . $name . "]" : $name;
// Get the element class and make sure it exist
$type = (isset($input['form']['type'])) ? $input['form']['type'] : "text";