Answers.Body: <p>Matrix fields can only be used as custom fields, on an element.</p>
  
  <p>If you really want to use them, you would need to create a custom Element Type (see the resources at the bottom of <a href="http://buildwithcraft.com/docs/plugins/working-with-elements" rel="nofollow">http://buildwithcraft.com/docs/plugins/working-with-elements</a>), and then create a Matrix field that is associated with your element type’s field layout.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-12T14:26:02.820Z
Answers.Text: Is it applied for craftcms 3.x as well or we can add directly now without creating the element type.
Answers.UserDisplayName: inrsaurabh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-12T23:53:33.820Z
Answers.Text: @inrsaurabh Same answer applies to Craft 3
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-23T18:28:23.543Z
Answers.LastActivityDate: 2014-09-23T18:28:23.543Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I'm just starting to explore the whole power of Craft and I'm really satisfied with its possibilities so far.</p>
  
  <p>But I can't get one thing done, so here's my question:</p>
  
  <p>Is it possible to use matrix fields in my very own plugins? I already finished a form with several fields just as text inputs and stuff but I really need to extend this thing with a matrix field.</p>
  
  <p>Am I just blind and it's documented anywhere or is it a more complicated task than I can imagine at this point?</p>
  
  <p>Thanks for your help.</p>
  
  <p>Jonas</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-23T13:49:08.587Z
Comments.Text: One thing you might want to consider, if all your plugin does is collects input, is to use something like Guest Entries/frontend edit form to do the same. If you do need to do some custom processing on the collected data, you might hook into any of the available events, like onSaveEntry.
Comments.UserDisplayName: Fred Carlsen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-23T14:07:40.067Z
Comments.Text: Don't know how you plan to store your data but you might want to take a look at the [Element API](http://buildwithcraft.com/docs/plugins/working-with-elements#creating-new-element-types) to create your own element and use it with any available fields (just like Entries, Assets, etc...)
Comments.UserDisplayName: Benjamin David
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-24T09:31:29.623Z
Comments.Text: Thanks guys, I will try Brandons solution which seems to be kinda the same Benjamin offered?! Anyway, thank you.
Comments.UserDisplayName: LikeAJohny
Tags: <matrix><field>
Title: Matrix fields within a plugin?
ThreadText: # Matrix fields within a plugin?
  
  (Asked by: username_0 on 2014-09-23)
  
  I'm just starting to explore the whole power of Craft and I'm really satisfied with its possibilities so far.
  
  But I can't get one thing done, so here's my question:
  
  Is it possible to use matrix fields in my very own plugins? I already finished a form with several fields just as text inputs and stuff but I really need to extend this thing with a matrix field.
  
  Am I just blind and it's documented anywhere or is it a more complicated task than I can imagine at this point?
  
  Thanks for your help.
  
  Jonas
  
  **Tags:** matrix, field
  
  > **Comments:**
  > **username_1**: One thing you might want to consider, if all your plugin does is collects input, is to use something like Guest Entries/frontend edit form to do the same. If you do need to do some custom processing on the collected data, you might hook into any of the available events, like onSaveEntry.  
  > **username_2**: Don't know how you plan to store your data but you might want to take a look at the [Element API](http://buildwithcraft.com/docs/plugins/working-with-elements#creating-new-element-types) to create your own element and use it with any available fields (just like Entries, Assets, etc...)  
  > **username_0**: Thanks guys, I will try Brandons solution which seems to be kinda the same username_2 offered?! Anyway, thank you.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2014-09-23. Score: 1 | Accepted answer
  
  Matrix fields can only be used as custom fields, on an element.
  
  If you really want to use them, you would need to create a custom Element Type (see the resources at the bottom of <http://buildwithcraft.com/docs/plugins/working-with-elements>), and then create a Matrix field that is associated with your element type’s field layout.
  
  > **Comments:**
  > **username_4**: Is it applied for craftcms 3.x as well or we can add directly now without creating the element type.  
  > **username_3**: @username_4 Same answer applies to Craft 3  
  
  ---
  
  