Answers.Body: <p>If you are referring to a custom field to select products, one already exists:</p>
  
  <p><a href="https://i.sstatic.net/wGU7J.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wGU7J.png" alt="screenshot of product field type"></a></p>
  
  <p>If you are building a general attribute field for a plugin, taking a look at the B <code>BaseElementFieldType.php</code> within the craft/app filder (that the product field above extends) will give you clues on how to recreate the UI to select products (or any other element).</p>
  
  <p>The key file being <code>craft/app/templates/_includes/forms/elementSelect.html</code> which will show you how to instantiate the <code>Craft.BaseElementSelectInput</code> js class.</p>
  
  <p>Hope that points you in the right direction. I am not sure if there is a full guide out there on how to use<code>Craft.BaseElementSelectInput</code> js, but hopefully the above will get you most of the way there by looking at the code.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-07T05:24:32.930Z
Answers.Text: Thanks Luke - do you perhaps know any way to use Commerce Product fieldtype directly in my plugin? That would be the best way around probably.
Answers.UserDisplayName: Yuri Salimovskiy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-09T20:32:54.387Z
Answers.Text: Take a looks at http://craftcms.stackexchange.com/questions/895/is-it-possible-to-use-the-elementtype-modal-ui-for-a-custom-field-type-plugin
Answers.UserDisplayName: Luke Holder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-09T20:33:23.090Z
Answers.Text: If you want to use the fieldtype you would need to make your record an element type in craft to allow custom fields to be added to it.
Answers.UserDisplayName: Luke Holder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-06T16:13:02.840Z
Answers.LastActivityDate: 2016-05-06T16:13:02.840Z
Answers.UserDisplayName: Luke Holder
Body: <p>I'm writing plugin to extend Craft Commerce and I want to present a good way to select products in CP. </p>
  
  <p>I know I could use dropdown select for this, but using Craft's elementSelect would make the UI much nicer. Is there a way to use elementSelect dialog / fieldtype not just for entries or assets, but for custom data set (in my case, Commerce Products)?</p>
  
Tags: <fieldtypes><plugin-craftcommerce>
Title: Using elementSelect for third-party elements
ThreadText: # Using elementSelect for third-party elements
  
  (Asked by: username_0 on 2016-05-06)
  
  I'm writing plugin to extend Craft Commerce and I want to present a good way to select products in CP.
  
  I know I could use dropdown select for this, but using Craft's elementSelect would make the UI much nicer. Is there a way to use elementSelect dialog / fieldtype not just for entries or assets, but for custom data set (in my case, Commerce Products)?
  
  **Tags:** fieldtypes, plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-06. Score: 1 | Accepted answer
  
  If you are referring to a custom field to select products, one already exists:
  
  [![screenshot of product field type](https://i.sstatic.net/wGU7J.png)](https://i.sstatic.net/wGU7J.png)
  
  If you are building a general attribute field for a plugin, taking a look at the B `BaseElementFieldType.php` within the craft/app filder (that the product field above extends) will give you clues on how to recreate the UI to select products (or any other element).
  
  The key file being `craft/app/templates/_includes/forms/elementSelect.html` which will show you how to instantiate the `Craft.BaseElementSelectInput` js class.
  
  Hope that points you in the right direction. I am not sure if there is a full guide out there on how to use`Craft.BaseElementSelectInput` js, but hopefully the above will get you most of the way there by looking at the code.
  
  > **Comments:**
  > **username_0**: Thanks username_1 - do you perhaps know any way to use Commerce Product fieldtype directly in my plugin? That would be the best way around probably.  
  > **username_1**: Take a looks at http://craftcms.stackexchange.com/questions/895/is-it-possible-to-use-the-elementtype-modal-ui-for-a-custom-field-type-plugin  
  > **username_1**: If you want to use the fieldtype you would need to make your record an element type in craft to allow custom fields to be added to it.  
  
  ---
  
  