Skip to content

Commit

Permalink
Fixed Form and DataTransformer.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Feb 21, 2024
1 parent fba7649 commit 6e89095
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 2 additions & 3 deletions components/datatransformer/render.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

exports.make = function(instance, config) {
instance.state.notify = true;
instance.state.bind = true;
instance.on('ready', function() {

var fn = config.value ? new Function('value', config.value) : null;

instance.on('notify', function(value) {
if (fn) {
var val = fn(value);
if (val != undefined)
instance.set('value', val);
instance.set('value', val, 'nobind');
}
});

Expand Down
14 changes: 14 additions & 0 deletions components/form/render.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@

var invalid = false;
var modified = false;
var model = {};

for (var m of children) {

Expand All @@ -135,11 +136,24 @@
if (m.validate && !m.validate())
invalid = true;

if (m.state.bind && m.config.path && m.config.path.charAt(0) !== '@')
instance.write(model, m.config.path, m.state.value);

}

button && button.prop('disabled', !modified || invalid);
instance.set('invalid', invalid);
instance.set('modified', modified);

var tmp = instance.state.value || {};

if (!tmp)
tmp = {};

for (var key in model)
tmp[key] = model[key];

instance.set('value', tmp);
};

instance.on('state', function(e) {
Expand Down

0 comments on commit 6e89095

Please sign in to comment.