Answers.Body: <p>All the default field types are exposed as template <a href="http://twig.sensiolabs.org/doc/tags/macro.html" rel="nofollow noreferrer">macros</a> in <code>/craft/app/templates/_includes/forms.html</code>. Here's how you could easily create a DateTime input field:</p>
  
  <pre><code>{% import '_includes/forms' as forms %}
  
  {{ forms.date( {
      id : 'myDateField',
      name : 'myDateField',
      value : myDate | default
  } ) }}
  </code></pre>
  
  <p>Note that for the date field, <code>value</code> needs to be a valid DateTime object.</p>
  
  <p>Other input types – such as a plain text field – are created in a similar manner:</p>
  
  <pre><code>{{ forms.text( {
      id: 'myTextField',
      name: 'myTextField',
      value : myValue | default,
      placeholder : 'My Placeholder',
  } ) }}
  </code></pre>
  
  <p>Also note that as <code>_includes/forms</code> is outside the frontend <code>templates</code> folder, it will not be easily accessible outside the CP. If you want to include the form macros in a frontend template, see <a href="https://craftcms.stackexchange.com/a/4844/1098">the following SE thread</a> – I'm partial to Mike Pepper's answer, myself.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-03T02:18:14.630Z
Answers.Text: Fantastic! I figured there was a way other than copy/paste html.
Answers.UserDisplayName: Damon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-02T20:05:25.500Z
Answers.LastActivityDate: 2015-04-02T20:05:25.500Z
Answers.LastEditDate: 2017-04-13T12:51:00.303Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I am just experimenting with plugin development and would like to use the existing <a href="http://buildwithcraft.com/docs/date-time-fields" rel="nofollow">dateTime field type</a>. For no other reason than to maintain consistency throughout my application.</p>
  
  <p>Is there a way to call that field as a macro (for lack of better words) in my template or do I just view the generated source from one spot and copy/paste it into my templates?</p>
  
  <p>Thank you!</p>
  
Tags: <plugin-development><fieldtypes>
Title: Use default field type(s) within my plugin
ThreadText: # Use default field type(s) within my plugin
  
  (Asked by: username_0 on 2015-04-02)
  
  I am just experimenting with plugin development and would like to use the existing [dateTime field type](http://buildwithcraft.com/docs/date-time-fields). For no other reason than to maintain consistency throughout my application.
  
  Is there a way to call that field as a macro (for lack of better words) in my template or do I just view the generated source from one spot and copy/paste it into my templates?
  
  Thank you!
  
  **Tags:** plugin-development, fieldtypes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-04-02. Score: 3 | Accepted answer
  
  All the default field types are exposed as template [macros](http://twig.sensiolabs.org/doc/tags/macro.html) in `/craft/app/templates/_includes/forms.html`. Here's how you could easily create a DateTime input field:
  
  ```
  {% import '_includes/forms' as forms %}
  
  {{ forms.date( {
      id : 'myDateField',
      name : 'myDateField',
      value : myDate | default
  } ) }}
  
  ```
  
  Note that for the date field, `value` needs to be a valid DateTime object.
  
  Other input types – such as a plain text field – are created in a similar manner:
  
  ```
  {{ forms.text( {
      id: 'myTextField',
      name: 'myTextField',
      value : myValue | default,
      placeholder : 'My Placeholder',
  } ) }}
  
  ```
  
  Also note that as `_includes/forms` is outside the frontend `templates` folder, it will not be easily accessible outside the CP. If you want to include the form macros in a frontend template, see [the following SE thread](https://craftcms.stackexchange.com/a/4844/1098) – I'm partial to Mike Pepper's answer, myself.
  
  > **Comments:**
  > **username_0**: Fantastic! I figured there was a way other than copy/paste html.  
  
  ---
  
  