jonjamz / blaze-forms

Dead easy reactive forms with validation (Meteor).
https://atmospherejs.com/templates/forms
MIT License
113 stars 11 forks source link

Finalize v2 docs #92

Open jonjamz opened 8 years ago

jonjamz commented 8 years ago

Continued from #14.

7ammer commented 8 years ago

Hey @jonjamz, The validationValue needs amending in AdjustableNumberOfInputs

This outputs correctly for me...

validationValue: function (el, clean, template) {
   var values = $.map($(el).find("input"), function(e,i) {
      return $(e).val();
   });
  return values;
},
jonjamz commented 8 years ago

Thanks, fixed that one.

7ammer commented 8 years ago

Oops forgot to mention: TemplatesForms.registerFormElement should be ReactiveForms.createElement. ...Unless you're changing the method names in the next version.

jonjamz commented 8 years ago

Yes I think in the next update I will change the namespace and method names, but I will keep aliases for backwards compatibility.

7ammer commented 8 years ago

The validationValue for DateAndTime needs amending.

The below worked for me:

<template name="dateTimeElement">
    <div class="reactive-element">
        Date: <input type="date" value={{dateToString value}}><br>
        Time: <input type="time" value={{timeToString value}}>
    </div>
    {{#if submitted}}
        {{#if errorMessage}}<p class="error-message">{{errorMessage}}</p>{{/if}}
    {{/if}}
</template>
Template.dateTimeElement.helpers({
    dateToString: function(val){
        return new Date(val).toDateString();
    },
    timeToString: function(val){
        return new Date(val).toTimeString();
    }
});

ReactiveForms.createElement({
  template: 'dateTimeElement',
  validationEvent: 'change',
  validationValue: function (el, clean, template) {
      var values = $.map($(el).find("input"), function(e,i) {
          return $(e).val();
      });
      return new Date(values.join('T')); // A single Date Object.
  }
});
jonjamz commented 8 years ago

Fixed that one too, thanks.