hifive / hifivemain

main repository
http://www.htmlhifive.com/
Other
40 stars 10 forks source link

FormController.getValue()で取得する値を変換したい #585

Closed mtakeuchi closed 7 years ago

mtakeuchi commented 7 years ago

setValue()で設定した値に対して、あらかじめ定義したコンバータ関数で変換を行い、その結果を取得したい。

実装イメージ

<input type="checkbox" name="chk1">
<input type="text" name="txt1">
this.formController.setSettings({
  property: {
    chk1: {
      get: function(val) {
          return parseInt(val);
      }
    },
    txt1: {
      get: function(val) {
        return val * 1.08;
      }
    }
  }
});

this.formController.setValue({ chk1: "10", txt1: 100}); 
this.formController.getValue(); // { chk1: 10, txt1: 108 } 

関連issue #581

mtakeuchi commented 7 years ago

setSetting()に指定するオプションvalueFuncの機能と重複しているため取り下げ。