Body: <p>I need to get two text fields under the same custom form and have it return two different values to be stored in the database.  Right now with what I have, it's storing the same variable for both, which I get why it's happening, but I can't come up with a viable solution to return two values. </p>
  
  <p>setting the field</p>
  
  <pre><code>{% import "_includes/forms" as forms %}
  
  {{ forms.textField({
      label: 'Value 1',
      instructions: 'test',
      name: name,
      style: 'width: 50%',
      value: value})
  }}
  {{ forms.textField({
      label: 'Value 2',
      instructions: 'test',
      name: name,
      style: 'width: 50%',
      value: value})
  }}
  </code></pre>
  
  <p>Field function:</p>
  
  <pre><code>public function getInputHtml($value, ElementInterface $element = null): string
  {
      return Craft::$app-&gt;getView()-&gt;renderTemplate('custom-plugin/cloudinary_field',
          [
                  'name' =&gt; $this-&gt;handle,
                  'value' =&gt; $value,
                  'field' =&gt; $this,
          ]
      );
  }
  </code></pre>
  
  <p>How can I make these two text fields each return a value to be stored in the database?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-31T21:18:32.960Z
Comments.Text: You can store an array in your DB as json. Would that be enough or do you need a custom table in order to enable advanced searching/filtering?
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-31T21:21:08.380Z
Comments.Text: I believe that would work, but I'm hitting a wall trying to figure out how to use it as an array.
Comments.UserDisplayName: Mapbry
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-06T01:56:24.057Z
Comments.Text: I've got the json arrays working, however I can't get the two fields to store the data in craft when we hit save.  I believe it's because the input fields both have the same name.  I'd assume these field names need to be unique?  I found https://craftcms.stackexchange.com/questions/17808/more-than-one-field-for-a-fieldtype-plugin which mentions the defineContentAttribute function, but it does not appear to be available in craft 3.
Comments.UserDisplayName: Mapbry
Tags: <templating><craft3><field>
Title: Craft CMS 3 create custom field in plugin with two fields returning two values
ThreadText: # Craft CMS 3 create custom field in plugin with two fields returning two values
  
  (Asked by: username_0 on 2018-08-31)
  
  I need to get two text fields under the same custom form and have it return two different values to be stored in the database. Right now with what I have, it's storing the same variable for both, which I get why it's happening, but I can't come up with a viable solution to return two values.
  
  setting the field
  
  ```
  {% import "_includes/forms" as forms %}
  
  {{ forms.textField({
      label: 'Value 1',
      instructions: 'test',
      name: name,
      style: 'width: 50%',
      value: value})
  }}
  {{ forms.textField({
      label: 'Value 2',
      instructions: 'test',
      name: name,
      style: 'width: 50%',
      value: value})
  }}
  
  ```
  
  Field function:
  
  ```
  public function getInputHtml($value, ElementInterface $element = null): string
  {
      return Craft::$app->getView()->renderTemplate('custom-plugin/cloudinary_field',
          [
                  'name' => $this->handle,
                  'value' => $value,
                  'field' => $this,
          ]
      );
  }
  
  ```
  
  How can I make these two text fields each return a value to be stored in the database?
  
  **Tags:** templating, craft3, field
  
  > **Comments:**
  > **username_1**: You can store an array in your DB as json. Would that be enough or do you need a custom table in order to enable advanced searching/filtering?  
  > **username_0**: I believe that would work, but I'm hitting a wall trying to figure out how to use it as an array.  
  > **username_0**: I've got the json arrays working, however I can't get the two fields to store the data in craft when we hit save.  I believe it's because the input fields both have the same name.  I'd assume these field names need to be unique?  I found https://craftcms.stackexchange.com/questions/17808/more-than-one-field-for-a-fieldtype-plugin which mentions the defineContentAttribute function, but it does not appear to be available in craft 3.  
  
  ---
  
  ## 0 answers
  
  