Giter Club home page Giter Club logo

autoform-pickadate's Introduction

robertlowe:autoform-pickadate

An add-on Meteor package for aldeed:autoform. Provides two custom input types, "pickadate" and "pickatime", which renders an input using the pickadate plugin.

Prerequisites

None

In a Meteor app directory, enter:

$ meteor add robertlowe:autoform-pickadate

Installation

In a Meteor app directory, enter:

$ meteor add robertlowe:autoform-pickadate

Usage

Specify "pickadate" or "pickatime" for the type attribute of any input. This can be done in a number of ways: " In the schema, which will then work with a quickForm or afQuickFields:

{
  date: {
    type: Date,
    autoform: {
      type: "pickadate"
    }
  },

  time: {
    type: Date,
    autoform: {
      type: "pickatime"
      pickatimeOptions: {
        format: "H:i"
      }
    }
  }

}

Or on the afFieldInput component or any component that passes along attributes to afFieldInput:

{{> afQuickField name="typeTest" type="pickadate"}}
{{> afFormGroup name="typeTest" type="pickadate"}}
{{> afFieldInput name="typeTest" type="pickadate"}}
{{> afQuickField name="typeTest" type="pickatime"}}
{{> afFormGroup name="typeTest" type="pickatime"}}
{{> afFieldInput name="typeTest" type="pickatime"}}

Automatic Type Conversions

This input type is intended to be used with type: Date schema keys, but it also works with other schema types. Here's a list:

  • Date: Value is stored as a Date object representing midnight in the UTC timezone on the morning of the selected date.
  • String: Value is stored as a string representation of the selected date in ISO format, e.g., "2014-11-25".
  • Number: Value is stored as the result of calling getTime() on the Date object (representing midnight in the UTC timezone on the morning of the selected date).
  • Array: If the schema expects an array of Date or String or Number, the value is converted to a one-item array and stored.

To provide pickadate options, set a pickadateOptions attribute equal to a helper that returns the options object. Most of the data-date attributes that the plugin recognizes should also work.

Customizing Appearance

If you want to customize the appearance of the input more, for example to use input group add-ons both before and after the field, use the aldeed:template-extension package to replace the "afPickadate" template, like this:

<template name="dpReplacement">
  <div class='input-group date'>
    <input type="text" value="" {{atts}}/>
    <span class="input-group-addon">
      <span class="glyphicon glyphicon-calendar"></span>
    </span>
  </div>
</template>
Template.dpReplacement.replaces("afPickadate");

Contributing

Anyone is welcome to contribute. Fork, make your changes, and then submit a pull request.

autoform-pickadate's People

Contributors

arvi avatar robertlowe avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

pagebakers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.