Commit bfc03e87 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

FormGroup.js: added setRequired().

QfqForm.js: support `required` configuration attribute.
parent 8c5525df
/.plantuml
/doc/plantuml
/extension/Documentation/_make/build
/qfq.ini
/doc/phpdoc
......
......@@ -78,10 +78,18 @@ QfqNS.Element = QfqNS.Element || {};
return $formGroup;
};
/**
* @public
* @returns {boolean}
*/
n.FormGroup.prototype.hasLabel = function () {
return this.$label.length > 0;
};
/**
* @public
* @returns {boolean}
*/
n.FormGroup.prototype.hasHelpBlock = function () {
return this.$helpBlock.length > 0;
};
......@@ -92,11 +100,16 @@ QfqNS.Element = QfqNS.Element || {};
* Read-only is mapped onto setEnabled(). We do not distinguish between those two.
*
* @param readonly
* @public
*/
n.FormGroup.prototype.setReadOnly = function (readonly) {
this.setEnabled(!readonly);
};
/**
* @public
* @param enabled
*/
n.FormGroup.prototype.setEnabled = function (enabled) {
this.$element.prop('disabled', !enabled);
......@@ -111,6 +124,10 @@ QfqNS.Element = QfqNS.Element || {};
}
};
/**
* @public
* @param hidden
*/
n.FormGroup.prototype.setHidden = function (hidden) {
if (hidden) {
this.$formGroup.addClass("hidden");
......@@ -119,6 +136,10 @@ QfqNS.Element = QfqNS.Element || {};
}
};
n.FormGroup.prototype.setRequired = function (required) {
this.$element.prop('required', true);
};
/**
* Read Only click handler.
......
......@@ -106,6 +106,11 @@ var QfqNS = QfqNS || {};
configuration.disabled = n.Helper.stringToBool(disabledVal);
}
var requiredVal = $element.data("required");
if (requiredVal !== undefined) {
configuration.required = n.Helper.stringToBool(requiredVal);
}
configurationArray.push(configuration);
} catch (e) {
n.Log.error(e.message);
......@@ -689,6 +694,10 @@ var QfqNS = QfqNS || {};
if (configurationItem.hidden !== undefined) {
element.setHidden(configurationItem.hidden);
}
if (configurationItem.required !== undefined) {
element.setRequired(configuration.required);
}
} catch (e) {
n.Log.error(e.message);
}
......
......@@ -81,7 +81,7 @@
</div>
<form id="myForm" class="form-horizontal">
<form id="myForm" class="form-horizontal" data-toggle="validator">
<div class="form-group">
<div class="col-md-2">
......@@ -174,6 +174,7 @@
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/validator.min.js"></script>
<script src="../js/jqx-all.js"></script>
<script src="../js/EventEmitter.min.js"></script>
<script src="../js/qfq.debug.js"></script>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment