aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/sprinkles/FormGenerator
diff options
context:
space:
mode:
Diffstat (limited to 'main/app/sprinkles/FormGenerator')
-rw-r--r--main/app/sprinkles/FormGenerator/asset-bundles.json26
-rw-r--r--main/app/sprinkles/FormGenerator/assets/js/widget-formGenerator.js101
-rw-r--r--main/app/sprinkles/FormGenerator/bower.json56
-rw-r--r--main/app/sprinkles/FormGenerator/composer.json48
-rw-r--r--main/app/sprinkles/FormGenerator/routes/FormGenerator.php2
-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
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/FormGenerator.html.twig34
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/confirm.html.twig52
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/alert.html.twig4
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/checkbox.html.twig2
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/hidden.html.twig2
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/select.html.twig6
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/text.html.twig10
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/textarea.html.twig5
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/modal.html.twig93
-rw-r--r--main/app/sprinkles/FormGenerator/templates/FormGenerator/typehead.html.twig20
-rw-r--r--main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.php28
-rw-r--r--main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json18
-rw-r--r--main/app/sprinkles/FormGenerator/tests/Unit/data/good.json128
28 files changed, 381 insertions, 363 deletions
diff --git a/main/app/sprinkles/FormGenerator/asset-bundles.json b/main/app/sprinkles/FormGenerator/asset-bundles.json
index b763d55..43ea863 100644
--- a/main/app/sprinkles/FormGenerator/asset-bundles.json
+++ b/main/app/sprinkles/FormGenerator/asset-bundles.json
@@ -1,17 +1,17 @@
{
- "bundle": {
- "js/FormGenerator": {
- "scripts": [
- "vendor/bootstrap3-typeahead/bootstrap3-typeahead.js",
- "js/widget-formGenerator.js"
- ],
- "options": {
- "result": {
- "type": {
- "scripts": "plain"
- }
- }
- }
+ "bundle": {
+ "js/FormGenerator": {
+ "scripts": [
+ "vendor/bootstrap3-typeahead/bootstrap3-typeahead.js",
+ "js/widget-formGenerator.js"
+ ],
+ "options": {
+ "result": {
+ "type": {
+ "scripts": "plain"
+ }
}
+ }
}
+ }
}
diff --git a/main/app/sprinkles/FormGenerator/assets/js/widget-formGenerator.js b/main/app/sprinkles/FormGenerator/assets/js/widget-formGenerator.js
index 52743f6..6cfcce8 100644
--- a/main/app/sprinkles/FormGenerator/assets/js/widget-formGenerator.js
+++ b/main/app/sprinkles/FormGenerator/assets/js/widget-formGenerator.js
@@ -10,20 +10,20 @@
* @license MIT
*/
-;(function($, window, document, undefined) {
- "use strict";
+;(function ($, window, document, undefined) {
+ "use strict";
// Define plugin name and defaults.
var pluginName = "formGenerator",
defaults = {
- DEBUG : false,
- mainAlertElement : $('#alerts-page'),
- redirectAfterSuccess : true,
- autofocusModalElement : true
+ DEBUG: false,
+ mainAlertElement: $('#alerts-page'),
+ redirectAfterSuccess: true,
+ autofocusModalElement: true
};
// Constructor
- function Plugin (element, options) {
+ function Plugin(element, options) {
this.elements = element;
this.$elements = $(this.elements);
this.settings = $.extend(true, {}, defaults, options);
@@ -31,7 +31,11 @@
this._name = pluginName;
// Detect changes to element attributes
- this.$elements.attrchange({ callback: function (event) { this.elements = event.target; }.bind(this) });
+ this.$elements.attrchange({
+ callback: function (event) {
+ this.elements = event.target;
+ }.bind(this)
+ });
// Initialise ufAlerts
if (!this.settings.mainAlertElement.data('ufAlerts')) {
@@ -46,21 +50,21 @@
/**
* Bind the display action for a form to the button
*/
- display: function() {
+ display: function () {
this.$elements.on('click', $.proxy(this._fetchForm, this));
return this.$elements;
},
/**
* Bind the confirm action to the button
*/
- confirm: function() {
+ confirm: function () {
this.$elements.on('click', $.proxy(this._fetchConfirmModal, this));
return this.$elements;
},
/**
* Fetch the form HTML
*/
- _fetchForm: function(event) {
+ _fetchForm: function (event) {
// Get the button element
var button = event.currentTarget;
@@ -72,14 +76,15 @@
}
// Delete any existing instance of the form with the same name
- if($('#' + box_id).length) {
+ if ($('#' + box_id).length) {
$('#' + box_id).remove();
}
// Prepare the ajax payload
var payload = $.extend({
- box_id: box_id}
- , button.dataset);
+ box_id: box_id
+ }
+ , button.dataset);
// Fetch and render the form
$.ajax({
@@ -88,19 +93,19 @@
data: payload,
cache: false
})
- .done($.proxy(this._displayForm, this, box_id, button))
- .fail($.proxy(this._displayFailure, this, button));
+ .done($.proxy(this._displayForm, this, box_id, button))
+ .fail($.proxy(this._displayFailure, this, button));
},
/**
* Displays the form modal and set up ufForm
*/
- _displayForm: function(box_id, button, data) {
+ _displayForm: function (box_id, button, data) {
// Trigger pre-display event
$(button).trigger("displayForm." + this._name);
// Append the form as a modal dialog to the body
- $( "body" ).append(data);
+ $("body").append(data);
$('#' + box_id).modal('show');
// Set focus on first element
@@ -111,7 +116,7 @@
}
// Setup ufAlerts
- var boxMsgTarget = $("#"+box_id+" #form-alerts");
+ var boxMsgTarget = $("#" + box_id + " #form-alerts");
// Show the alert. We could have info alert coming in
if (!boxMsgTarget.data('ufAlerts')) {
@@ -122,15 +127,15 @@
// Setup the loaded form with ufForm
$('#' + box_id).find("form").ufForm({
validators: validators,
- msgTarget: $("#"+box_id+" #form-alerts")
+ msgTarget: $("#" + box_id + " #form-alerts")
})
- .on("submitSuccess.ufForm", $.proxy(this._formPostSuccess, this, box_id, button))
- .on("submitError.ufForm", $.proxy(this._displayFormFaillure, this, box_id, button));
+ .on("submitSuccess.ufForm", $.proxy(this._formPostSuccess, this, box_id, button))
+ .on("submitError.ufForm", $.proxy(this._displayFormFaillure, this, box_id, button));
},
/**
* Action done when a form is successful
*/
- _formPostSuccess: function(box_id, button, event, data) {
+ _formPostSuccess: function (box_id, button, event, data) {
// Trigger success event
$(button).trigger("formSuccess." + this._name, data);
@@ -146,7 +151,7 @@
/**
* Fetch confirmation modal
*/
- _fetchConfirmModal: function(event) {
+ _fetchConfirmModal: function (event) {
// Get the button element
var button = event.currentTarget;
@@ -158,7 +163,7 @@
}
// Delete any existing instance of the form with the same name
- if($('#' + box_id).length) {
+ if ($('#' + box_id).length) {
$('#' + box_id).remove();
}
@@ -179,19 +184,19 @@
data: payload,
cache: false
})
- .done($.proxy(this._displayConfirmation, this, box_id, button))
- .fail($.proxy(this._displayFailure, this, button));
+ .done($.proxy(this._displayConfirmation, this, box_id, button))
+ .fail($.proxy(this._displayFailure, this, button));
},
/**
* Display confirmation modal
*/
- _displayConfirmation: function(box_id, button, data) {
+ _displayConfirmation: function (box_id, button, data) {
// Trigger pre-display event
$(button).trigger("displayConfirmation." + this._name);
// Append the form as a modal dialog to the body
- $( "body" ).append(data);
+ $("body").append(data);
$('#' + box_id).modal('show');
$('#' + box_id + ' .js-confirm').on('click', $.proxy(this._sendConfirmation, this, box_id, button));
@@ -199,7 +204,7 @@
/**
* Send confirmation query
*/
- _sendConfirmation: function(box_id, button) {
+ _sendConfirmation: function (box_id, button) {
// Prepare payload
var url = $(button).data('postUrl');
@@ -212,17 +217,17 @@
// Send ajax
$.ajax({
- type: method,
- url: url,
- data: data
+ type: method,
+ url: url,
+ data: data
})
- .done($.proxy(this._confirmationSuccess, this, box_id, button))
- .fail($.proxy(this._displayConfirmationFaillure, this, box_id, button));
+ .done($.proxy(this._confirmationSuccess, this, box_id, button))
+ .fail($.proxy(this._displayConfirmationFaillure, this, box_id, button));
},
- /**
+ /**
* Action done when a confirmation request is successful
*/
- _confirmationSuccess: function(box_id, button, data) {
+ _confirmationSuccess: function (box_id, button, data) {
// Trigger success event
$(button).trigger("confirmSuccess." + this._name, data);
@@ -244,14 +249,14 @@
/**
* Failure callback for ajax requests. Displays the error in the main alertElement
*/
- _displayFailure: function(button, response) {
+ _displayFailure: function (button, response) {
$(button).trigger("error." + this._name);
if ((typeof site !== "undefined") && site.debug.ajax && response.responseText) {
document.write(response.responseText);
document.close();
} else {
if (this.settings.DEBUG) {
- $.error("Error (" + response.status + "): " + response.responseText );
+ $.error("Error (" + response.status + "): " + response.responseText);
}
this.settings.mainAlertElement.ufAlerts('clear').ufAlerts('fetch').ufAlerts('render');
}
@@ -259,18 +264,18 @@
/**
* Faillure callback for ajax requests to be displayed in a modal form
*/
- _displayFormFaillure: function(box_id, button) {
+ _displayFormFaillure: function (box_id, button) {
$(button).trigger("error." + this._name);
- $("#"+box_id+" #form-alerts").show();
+ $("#" + box_id + " #form-alerts").show();
},
/**
* Faillure callback for ajax requests to be displayed in a confirmation form
*/
- _displayConfirmationFaillure: function(box_id, button) {
+ _displayConfirmationFaillure: function (box_id, button) {
$(button).trigger("error." + this._name);
// Setup ufAlerts
- var boxMsgTarget = $("#"+box_id+" #confirmation-alerts");
+ var boxMsgTarget = $("#" + box_id + " #confirmation-alerts");
// Show the alert. We could have info alert coming in
if (!boxMsgTarget.data('ufAlerts')) {
@@ -281,7 +286,7 @@
/**
* Completely destroy the ufAlerts plugin on the element.
*/
- destroy: function() {
+ destroy: function () {
// Unbind any bound events
this.$elements.off('.' + this._name);
@@ -296,7 +301,7 @@
});
// Handles instantiation and access to non-private methods.
- $.fn[pluginName] = function(methodOrOptions) {
+ $.fn[pluginName] = function (methodOrOptions) {
// If the plugin is called on a non existing element, return nothing
if (this.length == 0) {
@@ -319,11 +324,11 @@
var options = Array.prototype.slice.call(arguments, 1)[0];
}
else {
- $.error( 'Method ' + methodOrOptions + ' is private!' );
+ $.error('Method ' + methodOrOptions + ' is private!');
}
}
else {
- $.error( 'Method ' + methodOrOptions + ' is invalid.' );
+ $.error('Method ' + methodOrOptions + ' is invalid.');
}
// Only initalise if not previously done.
@@ -337,7 +342,7 @@
// Run the required method
return instance[method](options);
} else {
- $.error( 'Method ' + method + ' does not exist.' );
+ $.error('Method ' + method + ' does not exist.');
}
};
diff --git a/main/app/sprinkles/FormGenerator/bower.json b/main/app/sprinkles/FormGenerator/bower.json
index 723b5cc..6ce7156 100644
--- a/main/app/sprinkles/FormGenerator/bower.json
+++ b/main/app/sprinkles/FormGenerator/bower.json
@@ -1,30 +1,30 @@
{
- "name": "formgenerator-assets",
- "version": "0.0.1",
- "homepage": "https://github.com/lcharette/UF_FormGenerator",
- "authors": [
- "lcharette"
- ],
- "moduleType": [
- "node"
- ],
- "license": "MIT",
- "ignore": [
- "**/.*",
- "node_modules",
- "bower_components",
- "assets/vendor",
- "examples",
- "demo-resources",
- "demo",
- "test",
- "tests"
- ],
- "dependencies": {
- "bootstrap3-typeahead": "~3.1.0"
- },
- "resolutions": {
- "jquery": ">= 2.2.4",
- "bootstrap": "3.x"
- }
+ "name": "formgenerator-assets",
+ "version": "0.0.1",
+ "homepage": "https://github.com/lcharette/UF_FormGenerator",
+ "authors": [
+ "lcharette"
+ ],
+ "moduleType": [
+ "node"
+ ],
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "assets/vendor",
+ "examples",
+ "demo-resources",
+ "demo",
+ "test",
+ "tests"
+ ],
+ "dependencies": {
+ "bootstrap3-typeahead": "~3.1.0"
+ },
+ "resolutions": {
+ "jquery": ">= 2.2.4",
+ "bootstrap": "3.x"
+ }
}
diff --git a/main/app/sprinkles/FormGenerator/composer.json b/main/app/sprinkles/FormGenerator/composer.json
index e37a372..797e029 100644
--- a/main/app/sprinkles/FormGenerator/composer.json
+++ b/main/app/sprinkles/FormGenerator/composer.json
@@ -1,25 +1,29 @@
{
- "name": "lcharette/uf_formgenerator",
- "type": "userfrosting-sprinkle",
- "description": "Form generator for UserFrosting V4",
- "keywords": ["Form", "generator", "userfrosting"],
- "homepage": "https://github.com/lcharette/UF_FormGenerator",
- "license" : "MIT",
- "authors" : [
- {
- "name": "Louis Charette",
- "homepage": "https://github.com/lcharette"
- }
- ],
- "require": {
- "php": ">=5.6"
- },
- "autoload": {
- "psr-4": {
- "UserFrosting\\Sprinkle\\FormGenerator\\": "src/"
- }
- },
- "extra": {
- "installer-name": "FormGenerator"
+ "name": "lcharette/uf_formgenerator",
+ "type": "userfrosting-sprinkle",
+ "description": "Form generator for UserFrosting V4",
+ "keywords": [
+ "Form",
+ "generator",
+ "userfrosting"
+ ],
+ "homepage": "https://github.com/lcharette/UF_FormGenerator",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Louis Charette",
+ "homepage": "https://github.com/lcharette"
}
+ ],
+ "require": {
+ "php": ">=5.6"
+ },
+ "autoload": {
+ "psr-4": {
+ "UserFrosting\\Sprinkle\\FormGenerator\\": "src/"
+ }
+ },
+ "extra": {
+ "installer-name": "FormGenerator"
+ }
}
diff --git a/main/app/sprinkles/FormGenerator/routes/FormGenerator.php b/main/app/sprinkles/FormGenerator/routes/FormGenerator.php
index 0b7ea51..c770793 100644
--- a/main/app/sprinkles/FormGenerator/routes/FormGenerator.php
+++ b/main/app/sprinkles/FormGenerator/routes/FormGenerator.php
@@ -9,4 +9,4 @@
global $app;
-$app->get('/forms/confirm','UserFrosting\Sprinkle\FormGenerator\Controller\FormGeneratorController:confirm'); \ No newline at end of file
+$app->get('/forms/confirm', 'UserFrosting\Sprinkle\FormGenerator\Controller\FormGeneratorController:confirm'); \ No newline at end of file
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";
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/FormGenerator.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/FormGenerator.html.twig
index c902064..688c96c 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/FormGenerator.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/FormGenerator.html.twig
@@ -12,22 +12,24 @@
{{ alert.generate(input) }}
{% else %}
{% if not input.hidden %}
- <div class="form-group has-feedback">
- {% if formLayout == 'horizontal' %}<label for="{{input.id}}" class="col-sm-2 control-label">{% else %}<label for="{{input.id}}">{% endif %}
- {% if input.label %}{{translate(input.label)}}{% else %}&nbsp;{% endif %}
- </label>
- {% if formLayout == 'horizontal' %}<div class="col-sm-10">{% endif %}
- {% if input.type == "textarea" %}
- {{ textarea.generate(input) }}
- {% elseif input.type == "checkbox" %}
- {{ checkbox.generate(input) }}
- {% elseif input.type == "select" %}
- {{ select.generate(input) }}
- {% else %}
- {{ text.generate(input) }}
- {% endif %}
- {% if formLayout == 'horizontal' %}</div>{% endif %}
- </div>
+ <div class="form-group has-feedback">
+ {% if formLayout == 'horizontal' %}<label for="{{ input.id }}" class="col-sm-2 control-label">{% else %}
+ <label for="{{ input.id }}">{% endif %}
+ {% if input.label %}{{ translate(input.label) }}{% else %}&nbsp;{% endif %}
+ </label>
+ {% if formLayout == 'horizontal' %}
+ <div class="col-sm-10">{% endif %}
+ {% if input.type == "textarea" %}
+ {{ textarea.generate(input) }}
+ {% elseif input.type == "checkbox" %}
+ {{ checkbox.generate(input) }}
+ {% elseif input.type == "select" %}
+ {{ select.generate(input) }}
+ {% else %}
+ {{ text.generate(input) }}
+ {% endif %}
+ {% if formLayout == 'horizontal' %}</div>{% endif %}
+ </div>
{% endif %}
{% endif %}
{% endfor %} \ No newline at end of file
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/confirm.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/confirm.html.twig
index 96d0072..67ba757 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/confirm.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/confirm.html.twig
@@ -1,28 +1,30 @@
-<div id='{{box_id}}' class='modal fade'>
- <div class="modal-dialog">
- <div class="modal-content">
- <div class='modal-header'>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- <h4 class='modal-title'>{% if box_title %}{{ translate(box_title) }}{% else %}{{translate("CONFIRM")}}{% endif %}</h4>
- </div>
- <div class='modal-body'>
- <div id="confirmation-alerts"></div>
- <h4>
- {% if confirm_message %}{{ translate(confirm_message) }}{% else %}{{translate("CONFIRM.MESSAGE")}}{% endif %}
- <br />
- <small>{% if confirm_warning %}{{ translate(confirm_warning) }}{% else %}{{translate("CONFIRM.WARNING")}}{% endif %}</small>
- </h4>
- <br>
- <div class='btn-group-action'>
- {% include "forms/csrf.html.twig" %}
- <button type='button' class='btn btn-danger btn-lg btn-block js-confirm'>{% if confirm_button %}{{ translate(confirm_button) }}{% else %}{{translate("CONFIRM.YES")}}{% endif %}</button>
- <button type='button' class='btn btn-default btn-lg btn-block' data-dismiss='modal'>{% if cancel_button %}{{ translate(cancel_button) }}{% else %}{{translate("CANCEL")}}{% endif %}</button>
- </div>
+<div id='{{ box_id }}' class='modal fade'>
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class='modal-header'>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">×</span>
+ </button>
+ <h4 class='modal-title'>{% if box_title %}{{ translate(box_title) }}{% else %}{{ translate("CONFIRM") }}{% endif %}</h4>
+ </div>
+ <div class='modal-body'>
+ <div id="confirmation-alerts"></div>
+ <h4>
+ {% if confirm_message %}{{ translate(confirm_message) }}{% else %}{{ translate("CONFIRM.MESSAGE") }}{% endif %}
+ <br />
+ <small>{% if confirm_warning %}{{ translate(confirm_warning) }}{% else %}{{ translate("CONFIRM.WARNING") }}{% endif %}</small>
+ </h4>
+ <br>
+ <div class='btn-group-action'>
+ {% include "forms/csrf.html.twig" %}
+ <button type='button'
+ class='btn btn-danger btn-lg btn-block js-confirm'>{% if confirm_button %}{{ translate(confirm_button) }}{% else %}{{ translate("CONFIRM.YES") }}{% endif %}</button>
+ <button type='button' class='btn btn-default btn-lg btn-block'
+ data-dismiss='modal'>{% if cancel_button %}{{ translate(cancel_button) }}{% else %}{{ translate("CANCEL") }}{% endif %}</button>
+ </div>
+ </div>
</div>
+ <!-- /.modal-content -->
</div>
- <!-- /.modal-content -->
- </div>
- <!-- /.modal-dialog -->
+ <!-- /.modal-dialog -->
</div> \ No newline at end of file
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/alert.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/alert.html.twig
index 21636f0..03409b5 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/alert.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/alert.html.twig
@@ -1,5 +1,5 @@
{% macro generate(input) %}
- <div class="alert {{input.class}}">
- {% if input.icon %}<i class="icon fa {{input.icon}}"></i> {% endif %}{{ translate(input.value) }}
+ <div class="alert {{ input.class }}">
+ {% if input.icon %}<i class="icon fa {{ input.icon }}"></i> {% endif %}{{ translate(input.value) }}
</div>
{% endmacro %} \ No newline at end of file
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/checkbox.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/checkbox.html.twig
index 9065651..95855c2 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/checkbox.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/checkbox.html.twig
@@ -1,5 +1,5 @@
{% macro generate(input) %}
<div class="checkbox icheck">
- <input{% for type,value in input %} {{type}}="{{value}}"{% endfor %}></input>
+ <input{% for type,value in input %} {{ type }}="{{ value }}"{% endfor %}></input>
</div>
{% endmacro %} \ No newline at end of file
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/hidden.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/hidden.html.twig
index a30fb7a..34c2d9d 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/hidden.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/hidden.html.twig
@@ -1,3 +1,3 @@
{% macro generate(input) %}
- <input{% for type,value in input %} {{type}}="{{value}}"{% endfor %}></input>
+ <input{% for type,value in input %} {{ type }}="{{ value }}"{% endfor %}></input>
{% endmacro %} \ No newline at end of file
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/select.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/select.html.twig
index 256c3f2..152947b 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/select.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/select.html.twig
@@ -1,5 +1,7 @@
{% macro generate(input) %}
- <select{% for type,value in input %}{% if type != "options" %} {{type}}="{{value}}"{% endif %}{% endfor %}>
- {% for option, label in input.options %}<option value="{{option}}" {% if (option == input.value) %}selected{% endif %}>{{translate(label)}}</option>{% endfor %}
+ <select{% for type,value in input %}{% if type != "options" %} {{ type }}="{{ value }}"{% endif %}{% endfor %}>
+ {% for option, label in input.options %}
+ <option value="{{ option }}"
+ {% if (option == input.value) %}selected{% endif %}>{{ translate(label) }}</option>{% endfor %}
</select>
{% endmacro %} \ No newline at end of file
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/text.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/text.html.twig
index 30beb5b..8551fbb 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/text.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/text.html.twig
@@ -1,10 +1,10 @@
{% macro generate(input) %}
{% if input.icon %}
- <div class="input-group">
- <span class="input-group-addon"><i class="fa {{input.icon}} fa-fw"></i></span>
+<div class="input-group">
+ <span class="input-group-addon"><i class="fa {{ input.icon }} fa-fw"></i></span>
{% else %}
<div class="form-group">
- {% endif %}
- <input{% for type,value in input %} {{type}}="{{value}}"{% endfor %}></input>
+ {% endif %}
+ <input{% for type,value in input %} {{ type }}="{{ value }}"{% endfor %}></input>
</div>
-{% endmacro %}
+ {% endmacro %}
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/textarea.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/textarea.html.twig
index ce5e2e7..d924be4 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/textarea.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/macros/textarea.html.twig
@@ -1,5 +1,6 @@
{% macro generate(input) %}
- {% if input.icon %}<div class="input-group"><span class="input-group-addon"><i class="fa {{input.icon}} fa-fw"></i></span>{% endif %}
- <textarea{% for type,value in input %} {{type}}="{{value}}"{% endfor %}>{{input.value}}</textarea>
+ {% if input.icon %}<div class="input-group">
+ <span class="input-group-addon"><i class="fa {{ input.icon }} fa-fw"></i></span>{% endif %}
+ <textarea{% for type,value in input %} {{ type }}="{{ value }}"{% endfor %}>{{ input.value }}</textarea>
{% if input.icon %}</div>{% endif %}
{% endmacro %} \ No newline at end of file
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/modal.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/modal.html.twig
index 3c66201..82d3ea0 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/modal.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/modal.html.twig
@@ -1,62 +1,65 @@
{% block modal %}
-<div id='{{box_id}}' class='modal fade'>
- <div class="modal-dialog {% block modal_size %}{% endblock %}" role="document">
- <div class="modal-content">
- <form name="ModalFormGenerator" method="{{ (form_method) ? form_method : 'post' }}" action="{{form_action}}">
- {% include "forms/csrf.html.twig" %}
- <div class='modal-header'>
- <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button>
- <h4 class='modal-title'>{% if box_title %}{{ translate(box_title) }}{% endif %}</h4>
- </div>
- <div class='modal-body'>
- <div id="form-alerts"></div>
- {% block form_content %}
- {% include 'FormGenerator/FormGenerator.html.twig' %}
- {% endblock %}
- </div>
- <div class='modal-footer'>
- <div class="row">
- {% if "submit" not in buttons.hidden %}
- <div class="col-xs-8 col-sm-4">
- <div class="vert-pad">
- <button type="submit" class="btn btn-block btn-lg btn-success js-submit"{% if 'submit' in buttons.disabled %} disabled{% endif %}>
- {% if submit_button %}{{ translate(submit_button) }}{% else %}{{translate("SUBMIT")}}{% endif %}
- </button>
- </div>
+ <div id='{{ box_id }}' class='modal fade'>
+ <div class="modal-dialog {% block modal_size %}{% endblock %}" role="document">
+ <div class="modal-content">
+ <form name="ModalFormGenerator" method="{{ (form_method) ? form_method : 'post' }}"
+ action="{{ form_action }}">
+ {% include "forms/csrf.html.twig" %}
+ <div class='modal-header'>
+ <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button>
+ <h4 class='modal-title'>{% if box_title %}{{ translate(box_title) }}{% endif %}</h4>
+ </div>
+ <div class='modal-body'>
+ <div id="form-alerts"></div>
+ {% block form_content %}
+ {% include 'FormGenerator/FormGenerator.html.twig' %}
+ {% endblock %}
</div>
- {% endif %}
- {% if "cancel" not in buttons.hidden %}
- <div class="col-xs-4 col-sm-3 pull-right">
- <div class="vert-pad">
- <button type="button" class="btn btn-block btn-lg btn-link" data-dismiss="modal"{% if 'cancel' in buttons.disabled %} disabled{% endif %}>
- {{ translate("CANCEL") }}
- </button>
+ <div class='modal-footer'>
+ <div class="row">
+ {% if "submit" not in buttons.hidden %}
+ <div class="col-xs-8 col-sm-4">
+ <div class="vert-pad">
+ <button type="submit"
+ class="btn btn-block btn-lg btn-success js-submit"{% if 'submit' in buttons.disabled %} disabled{% endif %}>
+ {% if submit_button %}{{ translate(submit_button) }}{% else %}{{ translate("SUBMIT") }}{% endif %}
+ </button>
+ </div>
+ </div>
+ {% endif %}
+ {% if "cancel" not in buttons.hidden %}
+ <div class="col-xs-4 col-sm-3 pull-right">
+ <div class="vert-pad">
+ <button type="button" class="btn btn-block btn-lg btn-link"
+ data-dismiss="modal"{% if 'cancel' in buttons.disabled %} disabled{% endif %}>
+ {{ translate("CANCEL") }}
+ </button>
+ </div>
+ </div>
+ {% endif %}
</div>
</div>
- {% endif %}
- </div>
+ </form>
</div>
- </form>
+ <!-- /.modal-content -->
+ </div>
+ <!-- /.modal-dialog -->
</div>
- <!-- /.modal-content -->
- </div>
- <!-- /.modal-dialog -->
-</div>
{% endblock %}
{% block scripts_page %}
<!-- Need to reload and reaply those since we're in modal -->
<script>
// Load the validator rules for this form
- var validators = {{validators|default('{}')| raw}};
+ var validators = {{ validators|default('{}')| raw }};
- $(function() {
- $('#{{box_id}}').iCheck({
- checkboxClass: 'icheckbox_square-blue',
- radioClass: 'iradio_square-blue',
- increaseArea: '20%' // optional
+ $(function () {
+ $('#{{ box_id }}').iCheck({
+ checkboxClass: 'icheckbox_square-blue',
+ radioClass: 'iradio_square-blue',
+ increaseArea: '20%' // optional
});
- $('#{{box_id}}').find('.js-select2').select2({ minimumResultsForSearch: Infinity, width: '100%' });
+ $('#{{ box_id }}').find('.js-select2').select2({minimumResultsForSearch: Infinity, width: '100%'});
});
</script>
{% endblock %} \ No newline at end of file
diff --git a/main/app/sprinkles/FormGenerator/templates/FormGenerator/typehead.html.twig b/main/app/sprinkles/FormGenerator/templates/FormGenerator/typehead.html.twig
index 150427a..3e5c079 100644
--- a/main/app/sprinkles/FormGenerator/templates/FormGenerator/typehead.html.twig
+++ b/main/app/sprinkles/FormGenerator/templates/FormGenerator/typehead.html.twig
@@ -1,15 +1,15 @@
{% extends "FormGenerator/modal.html.twig" %}
{% block scripts_page %}
-{{ parent() }}
+ {{ parent() }}
-<script>
- $("input[name='{{typeaheadInput}}']").typeahead({
- source: function(query, process) {
- return $.getJSON('{{typeaheadUrl}}', { input : query}, function(data) {
- return process(data);
- });
- }
- });
-</script>
+ <script>
+ $("input[name='{{ typeaheadInput }}']").typeahead({
+ source: function (query, process) {
+ return $.getJSON('{{ typeaheadUrl }}', {input: query}, function (data) {
+ return process(data);
+ });
+ }
+ });
+ </script>
{% endblock %} \ No newline at end of file
diff --git a/main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.php b/main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.php
index 066e98d..d75f4f7 100644
--- a/main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.php
+++ b/main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.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\Tests\Unit;
use UserFrosting\Tests\TestCase;
@@ -29,8 +30,7 @@ class FormGeneratorTest extends TestCase
{
var $basePath;
- public function setUp()
- {
+ public function setUp() {
parent::setUp();
$this->basePath = __DIR__ . '/data';
}
@@ -38,8 +38,7 @@ class FormGeneratorTest extends TestCase
/**
* Test the base `Test` element class works on it's own
*/
- public function testTextFormElement()
- {
+ public function testTextFormElement() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -76,8 +75,7 @@ class FormGeneratorTest extends TestCase
* value is passed to the constructor. Should return the same as the
* previous test, but with the `value` setup instead of empty
*/
- public function testTextFormElementWithData()
- {
+ public function testTextFormElementWithData() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -113,8 +111,7 @@ class FormGeneratorTest extends TestCase
* This test is the same as the one before, but we test the `owener` field with some data
* This make sure the `default` schema field will work correctly when empty data is passed
*/
- public function testTextFormElementWithEmptyData()
- {
+ public function testTextFormElementWithEmptyData() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -151,8 +148,7 @@ class FormGeneratorTest extends TestCase
* Test the Form Class.
* Run the test with no current values (empty form)
*/
- public function testForm()
- {
+ public function testForm() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -233,7 +229,7 @@ class FormGeneratorTest extends TestCase
'name' => 'active',
'id' => 'field_active',
'type' => 'checkbox',
- 'binary' => true
+ 'binary' => TRUE
],
'hidden' => [
'value' => 'Something',
@@ -257,8 +253,7 @@ class FormGeneratorTest extends TestCase
/**
* Test the Form Clas with values to make sure filled form works correctly
*/
- public function testFormWithData()
- {
+ public function testFormWithData() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -271,7 +266,7 @@ class FormGeneratorTest extends TestCase
"status" => 1,
"hiddenString" => "The Bar secret code is...",
"completion" => 12,
- "active" => true
+ "active" => TRUE
];
// Generate the form
@@ -351,7 +346,7 @@ class FormGeneratorTest extends TestCase
'id' => 'field_active',
'type' => 'checkbox',
'checked' => 'checked', //Value here !
- 'binary' => true
+ 'binary' => TRUE
],
'hidden' => [
'value' => 'Something',
@@ -376,8 +371,7 @@ class FormGeneratorTest extends TestCase
* Test a non existant input type. It's supposed to not find the class and
* default back to the `Text` element class.
*/
- public function testUndefinedFormElement()
- {
+ public function testUndefinedFormElement() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/bad.json');
$schema = new RequestSchemaRepository($loader->load());
diff --git a/main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json b/main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json
index 683add2..50f1c00 100644
--- a/main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json
+++ b/main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json
@@ -1,12 +1,12 @@
{
- "myField" : {
- "form" : {
- "type" : "foo"
- }
- },
- "myOtherField" : {
- "form" : {
- "value" : "Bar"
- }
+ "myField": {
+ "form": {
+ "type": "foo"
}
+ },
+ "myOtherField": {
+ "form": {
+ "value": "Bar"
+ }
+ }
}
diff --git a/main/app/sprinkles/FormGenerator/tests/Unit/data/good.json b/main/app/sprinkles/FormGenerator/tests/Unit/data/good.json
index 61d5233..1592515 100644
--- a/main/app/sprinkles/FormGenerator/tests/Unit/data/good.json
+++ b/main/app/sprinkles/FormGenerator/tests/Unit/data/good.json
@@ -1,67 +1,67 @@
{
- "number" : {
- "form" : {
- "type" : "number",
- "label" : "Project Number",
- "icon" : "fa-edit",
- "placeholder" : "Project Number"
- }
- },
- "name" : {
- "form" : {
- "type" : "text",
- "label" : "Project Name",
- "icon" : "fa-flag",
- "placeholder" : "Project Name"
- }
- },
- "owner" : {
- "form" : {
- "type" : "text",
- "label" : "Project Owner",
- "icon" : "fa-user",
- "id" : "owner",
- "placeholder" : "Project Owner",
- "default" : "Foo"
- }
- },
- "description" : {
- "form" : {
- "type" : "textarea",
- "label" : "Project Description",
- "icon" : "fa-pencil",
- "placeholder" : "Project Description",
- "rows" : 5
- }
- },
- "status" : {
- "form" : {
- "type" : "select",
- "label" : "Project Status",
- "options" : {
- "0" : "Closed",
- "1" : "Open"
- }
- }
- },
- "active" : {
- "form" : {
- "type" : "checkbox",
- "label" : "Active"
- }
- },
- "hidden" : {
- "form" : {
- "type" : "hidden",
- "value" : "Something"
- }
- },
- "alert" : {
- "form" : {
- "type" : "alert",
- "class" : "alert-success",
- "icon" : "fa-check",
- "value" : "You're awesome!"
- }
+ "number": {
+ "form": {
+ "type": "number",
+ "label": "Project Number",
+ "icon": "fa-edit",
+ "placeholder": "Project Number"
}
+ },
+ "name": {
+ "form": {
+ "type": "text",
+ "label": "Project Name",
+ "icon": "fa-flag",
+ "placeholder": "Project Name"
+ }
+ },
+ "owner": {
+ "form": {
+ "type": "text",
+ "label": "Project Owner",
+ "icon": "fa-user",
+ "id": "owner",
+ "placeholder": "Project Owner",
+ "default": "Foo"
+ }
+ },
+ "description": {
+ "form": {
+ "type": "textarea",
+ "label": "Project Description",
+ "icon": "fa-pencil",
+ "placeholder": "Project Description",
+ "rows": 5
+ }
+ },
+ "status": {
+ "form": {
+ "type": "select",
+ "label": "Project Status",
+ "options": {
+ "0": "Closed",
+ "1": "Open"
+ }
+ }
+ },
+ "active": {
+ "form": {
+ "type": "checkbox",
+ "label": "Active"
+ }
+ },
+ "hidden": {
+ "form": {
+ "type": "hidden",
+ "value": "Something"
+ }
+ },
+ "alert": {
+ "form": {
+ "type": "alert",
+ "class": "alert-success",
+ "icon": "fa-check",
+ "value": "You're awesome!"
+ }
+ }
}