Answers.Body: <p>The problem as I see it is that the call is happening on the front-end. Because of this, the template renderer is not looking for the template at <code>plugin1/templates/_field/input</code> as it normally would, but at <code>plugin1/_field/input</code>, which explains the error message.</p>
  
  <p>If Plugin 1 is your own plugin then you should be able to include the <code>templates</code> part of the path in the render call, for example:</p>
  
  <pre><code>return craft()-&gt;templates-&gt;render('templates/_field/input');
  </code></pre>
  
  <p>I haven't tested this but I think it should work. </p>
  
  <p>Alternatively, and I would recommend this, since this is a front-end call, you could create your own function <code>getFrontEndInputHtml()</code> to return the html appropriately.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-13T01:29:47.277Z
Answers.Text: My initial goal was to be able to target any plugin this way but I think your answer sums up what is possible here.  I can modify Plugin 1's render path or add an additional function to get the results I want for that plugin but that doesn't help me address any plugin I don't have control over.  For Field Types in other plugins, it appears I'll need to explore alternative routes to communicate with them or use the template data they use.
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-08T11:08:23.250Z
Answers.LastActivityDate: 2014-07-08T11:25:30.407Z
Answers.LastEditDate: 2014-07-08T11:25:30.407Z
Answers.UserDisplayName: Ben Croker
Body: <p><strong>Plugin 1</strong></p>
  
  <p>I have a plugin that is a custom fieldtype.  It works fine, and has a getInputHtml() method that behaves as expected.</p>
  
  <p><strong>Plugin 2</strong></p>
  
  <p>Now, I have a second plugin, where I want to output the HTML from the Plugin 1 getInputHtml() method.  </p>
  
  <p>I have the FieldModel:</p>
  
  <pre><code>$field = $field-&gt;getField();
  </code></pre>
  
  <p>I have the Plugin 1 fieldtype object</p>
  
  <pre><code>$fieldtype = craft()-&gt;fields-&gt;populateFieldType($field, $element);
  </code></pre>
  
  <p>And I call the getInputHtml() method:</p>
  
  <pre><code>$fieldtype-&gt;getInputHtml($field-&gt;handle, $value);
  </code></pre>
  
  <p>If I place the necessary files at the base of Plugin 2 <code>plugin2/templates/plugin1/_field/input</code> everything works fine.  But I can't seem to access the input HTML template in the context of Plugin 1: <code>plugin1/templates/_field/input</code></p>
  
  <p>I've tried to update the Template Path in various ways before calling $fieldtype->getInputHtml():</p>
  
  <pre><code>craft()-&gt;path-&gt;setTemplatesPath(craft()-&gt;path-&gt;getPluginsPath());
  craft()-&gt;path-&gt;setTemplatesPath(craft()-&gt;path-&gt;getPluginsPath() . 'plugin1/');
  craft()-&gt;path-&gt;setTemplatesPath(craft()-&gt;path-&gt;getCpTemplatesPath());
  </code></pre>
  
  <p>Everything I have tried has resulted in a template error:</p>
  
  <pre><code>Unable to find the template "plugin1/_field/input".
  </code></pre>
  
  <p>Any ideas on what I'm doing wrong?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-07T11:17:13.680Z
Comments.Text: is the call to Plugin 2 happening in a CP or action request?
Comments.UserDisplayName: Ben Croker
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-08T07:02:18.013Z
Comments.Text: The call from Plugin 2 to Plugin 1 is happening on the front-end (a variable passes of the call to the service layer).  At this point, this is a largely academic pursuit about paths.  This is really not a good idea because getInputHtml() is designed to work on the CP side only and comes (potentially) with a lot of extra baggage for anything involving the front-end.
Comments.UserDisplayName: Ben Parizek
Tags: <plugin-development>
Title: How do I call the getInputHtml() method of a custom fieldtype plugin from another plugin?
ThreadText: # How do I call the getInputHtml() method of a custom fieldtype plugin from another plugin?
  
  (Asked by: username_0 on 2014-07-04)
  
  **Plugin 1**
  
  I have a plugin that is a custom fieldtype. It works fine, and has a getInputHtml() method that behaves as expected.
  
  **Plugin 2**
  
  Now, I have a second plugin, where I want to output the HTML from the Plugin 1 getInputHtml() method.
  
  I have the FieldModel:
  
  ```
  $field = $field->getField();
  
  ```
  
  I have the Plugin 1 fieldtype object
  
  ```
  $fieldtype = craft()->fields->populateFieldType($field, $element);
  
  ```
  
  And I call the getInputHtml() method:
  
  ```
  $fieldtype->getInputHtml($field->handle, $value);
  
  ```
  
  If I place the necessary files at the base of Plugin 2 `plugin2/templates/plugin1/_field/input` everything works fine. But I can't seem to access the input HTML template in the context of Plugin 1: `plugin1/templates/_field/input`
  
  I've tried to update the Template Path in various ways before calling $fieldtype->getInputHtml():
  
  ```
  craft()->path->setTemplatesPath(craft()->path->getPluginsPath());
  craft()->path->setTemplatesPath(craft()->path->getPluginsPath() . 'plugin1/');
  craft()->path->setTemplatesPath(craft()->path->getCpTemplatesPath());
  
  ```
  
  Everything I have tried has resulted in a template error:
  
  ```
  Unable to find the template "plugin1/_field/input".
  
  ```
  
  Any ideas on what I'm doing wrong?
  
  **Tags:** plugin-development
  
  > **Comments:**
  > **username_1**: is the call to Plugin 2 happening in a CP or action request?  
  > **username_0**: The call from Plugin 2 to Plugin 1 is happening on the front-end (a variable passes of the call to the service layer).  At this point, this is a largely academic pursuit about paths.  This is really not a good idea because getInputHtml() is designed to work on the CP side only and comes (potentially) with a lot of extra baggage for anything involving the front-end.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-07-08. Score: 1 | Accepted answer
  
  The problem as I see it is that the call is happening on the front-end. Because of this, the template renderer is not looking for the template at `plugin1/templates/_field/input` as it normally would, but at `plugin1/_field/input`, which explains the error message.
  
  If Plugin 1 is your own plugin then you should be able to include the `templates` part of the path in the render call, for example:
  
  ```
  return craft()->templates->render('templates/_field/input');
  
  ```
  
  I haven't tested this but I think it should work.
  
  Alternatively, and I would recommend this, since this is a front-end call, you could create your own function `getFrontEndInputHtml()` to return the html appropriately.
  
  > **Comments:**
  > **username_0**: My initial goal was to be able to target any plugin this way but I think your answer sums up what is possible here.  I can modify Plugin 1's render path or add an additional function to get the results I want for that plugin but that doesn't help me address any plugin I don't have control over.  For Field Types in other plugins, it appears I'll need to explore alternative routes to communicate with them or use the template data they use.  
  
  ---
  
  