Answers.Body: <p>In order to render a template within your custom plugin you need to include your plugin handle in front of your template path. For example</p>
  
  <pre><code>plugin-handle/_components/fields/Regionselect_settings
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-20T21:09:13.433Z
Answers.LastActivityDate: 2018-09-20T21:09:13.433Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I'm trying to build a simple dropdown field with a pre-populated set of options, so I figured I'd just import most of the methods from Craft's native Dropdown field. The plugin name is <code>siteutilities</code> and the field name is <code>Regionselect</code>:</p>
  
  <pre><code>namespace kgrote\siteutilities\fields;
  
  use kgrote\siteutilities\SiteUtilities;
  
  use Craft;
  use craft\base\ElementInterface;
  use craft\fields\BaseOptionsField; 
  </code></pre>
  
  <p>This pulls in the code from <code>craft/vendor/craftcms/cms/src/fields/BaseOptionsField.php</code>.</p>
  
  <p>So now I want to render a custom settings template for my plugin:</p>
  
  <pre><code>public function getSettingsHtml()
  {
      return Craft::$app-&gt;getView()-&gt;renderTemplate(
          '_components/fields/Regionselect_settings',
          [
              'field' =&gt; $this,
          ]
      );
  }
  </code></pre>
  
  <p>But I get a Twig error:</p>
  
  <blockquote>
    <p>Unable to find the template
    “_components/fields/Regionselect_settings”.</p>
  </blockquote>
  
  <p>My plugin file structure looks like this:</p>
  
  <pre><code>kgrote
  |-siteutilities
    |-src
      |-fields
      |  |-Regionselect.php
      |-templates
      |  |-_components
      |    |-fields
      |      |-Regionselect_settings.html
      |-SiteUtilities.php
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-19T22:07:59.823Z
Comments.Text: It searches for your template as well. Are you sure it's the correct path? Do you use a custom module instead of a plugin eventually?
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-20T19:57:05.640Z
Comments.Text: @RobinSchambach I think so, I've updated the question with my plugin's file structure. And no I don't use a custom module, just a plugin.
Comments.UserDisplayName: kmgdev
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-20T19:58:27.953Z
Comments.Text: Why a php file? You can only render twig and html files. All others won't be parsed/proceed by Twig
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-20T20:01:43.137Z
Comments.Text: @RobinSchambach Sorry that was a typo, it's a HTML file, I've updated the question.
Comments.UserDisplayName: kmgdev
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-20T20:48:23.140Z
Comments.Text: You need to include your plugin handle at the first position `plugin-handle/_components/fields/Regionselect_settings`
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-20T21:07:16.827Z
Comments.Text: @RobinSchambach Ah ha! That did it! If you want to post it as an answer I'll mark it accepted.
Comments.UserDisplayName: kmgdev
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-20T21:09:48.410Z
Comments.Text: Sorry for being so slow. I somehow overview that mistake at the first sight.
Comments.UserDisplayName: Robin Schambach
Tags: <plugin-development><custom-fieldtype>
Title: Custom Plugin Field Using Wrong Template Path
ThreadText: # Custom Plugin Field Using Wrong Template Path
  
  (Asked by: username_0 on 2018-09-19)
  
  I'm trying to build a simple dropdown field with a pre-populated set of options, so I figured I'd just import most of the methods from Craft's native Dropdown field. The plugin name is `siteutilities` and the field name is `Regionselect`:
  
  ```
  namespace kgrote\siteutilities\fields;
  
  use kgrote\siteutilities\SiteUtilities;
  
  use Craft;
  use craft\base\ElementInterface;
  use craft\fields\BaseOptionsField; 
  
  ```
  
  This pulls in the code from `craft/vendor/craftcms/cms/src/fields/BaseOptionsField.php`.
  
  So now I want to render a custom settings template for my plugin:
  
  ```
  public function getSettingsHtml()
  {
      return Craft::$app->getView()->renderTemplate(
          '_components/fields/Regionselect_settings',
          [
              'field' => $this,
          ]
      );
  }
  
  ```
  
  But I get a Twig error:
  
  > Unable to find the template
  > “\_components/fields/Regionselect\_settings”.
  
  My plugin file structure looks like this:
  
  ```
  kgrote
  |-siteutilities
    |-src
      |-fields
      |  |-Regionselect.php
      |-templates
      |  |-_components
      |    |-fields
      |      |-Regionselect_settings.html
      |-SiteUtilities.php
  
  ```
  
  **Tags:** plugin-development, custom-fieldtype
  
  > **Comments:**
  > **username_1**: It searches for your template as well. Are you sure it's the correct path? Do you use a custom module instead of a plugin eventually?  
  > **username_0**: @username_1 I think so, I've updated the question with my plugin's file structure. And no I don't use a custom module, just a plugin.  
  > **username_1**: Why a php file? You can only render twig and html files. All others won't be parsed/proceed by Twig  
  > **username_0**: @username_1 Sorry that was a typo, it's a HTML file, I've updated the question.  
  > **username_1**: You need to include your plugin handle at the first position `plugin-handle/_components/fields/Regionselect_settings`  
  > **username_0**: @username_1 Ah ha! That did it! If you want to post it as an answer I'll mark it accepted.  
  > **username_1**: Sorry for being so slow. I somehow overview that mistake at the first sight.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-20. Score: 1 | Accepted answer
  
  In order to render a template within your custom plugin you need to include your plugin handle in front of your template path. For example
  
  ```
  plugin-handle/_components/fields/Regionselect_settings
  
  ```
  
  
  ---
  
  