Answers.Body: <p>As there was no simple answer that didn't require another plugin or javascript I revised my entry form to collect the date manually. Which is a bit of a pain, as the input format for the date has to be mm/dd/yyyy, which isn't normal in the UK.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-10T00:35:06.560Z
Answers.Text: Don't picture the Preparse plugin as "yet another plugin". It's a tool that actually should be part of every Craft install, so useful.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-10T15:57:42.610Z
Answers.Text: I'm coming from ExpressionEngine, and have been bitten by addons that are no longer supported and not updated, and so now I can't update the EE version. I don't want that to happen again. Part of Craft's attraction is that almost everything I want is part of the core so updating isn't a problem.
Answers.UserDisplayName: Paul Frost
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-10T16:06:05.950Z
Answers.Text: Have a look at all the maintainers: https://github.com/aelvan/Preparse-Field-Craft/commits/master. Brandon is a one of them and he's a big fan of that plugin. It's here to stay, even if Andre should remove it from GitHub, I bet there will be a replacement plugin within a few days.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-09T21:14:11.917Z
Answers.LastActivityDate: 2016-03-09T21:14:11.917Z
Answers.UserDisplayName: Paul Frost
Answers.Body: <p>You could use the <a href="https://github.com/aelvan/Preparse-Field-Craft" rel="nofollow">Preparse plugin</a> to create a field that is automatically updated with the <code>eventDate</code> value whenever the entry is saved. It wouldn't be a datetime field, but if you stored the <em>timestamp</em> (i.e. <code>{{ dateString|date('U') }}</code>) it'd be easy to <em>use</em> as such.</p>
  
  <p>Another option is to have an hidden input in your form for the <code>eventDate</code> datetime field, and use JavaScript to set its value whenever the <code>&lt;select&gt;</code> input changes (i.e. listen for the <code>change</code> event for the latter, in your JS).</p>
  
  <p>The third option would be to write a plugin which listens to the <code>entries.beforeSaveEntry</code> event in order to set the <code>eventDate</code> value from the dropdown field.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-10T00:39:08.957Z
Answers.Text: Auto Expire plugin allows to copy to a Date/Time field.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-02T08:34:54.713Z
Answers.LastActivityDate: 2016-03-02T08:34:54.713Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I have the following code in my form, but I'd like to also save the eventDate of the selected entry into a separate date field to enable sorting/selection later.</p>
  
  <pre><code>&lt;label for="eventName"&gt;Event
  &lt;select id="eventName" name="fields[eventName]"&gt;  
    &lt;option value=""&gt;select from list&lt;/option&gt;
      {% set events = craft.entries.find({section:'events,activities', eventDate : "&gt;= " ~ now.w3cDate() , order:'eventDate'}) %}
      {% if events %}
          {% for entry in events %}                
              &lt;option value="{{ entry.eventDate.format('D j M') }},{{ entry.eventName }}"&gt;{{ entry.eventDate.format('D j M') }},{{ entry.eventName }}&lt;/option&gt;
          {% endfor %}
      {% endif %}
  &lt;/select&gt;            
  &lt;/label&gt;
  </code></pre>
  
Tags: <form>
Title: Possible to set 2 data fields within 1 select option?
ThreadText: # Possible to set 2 data fields within 1 select option?
  
  (Asked by: username_0 on 2016-03-01)
  
  I have the following code in my form, but I'd like to also save the eventDate of the selected entry into a separate date field to enable sorting/selection later.
  
  ```
  <label for="eventName">Event
  <select id="eventName" name="fields[eventName]">  
    <option value="">select from list</option>
      {% set events = craft.entries.find({section:'events,activities', eventDate : ">= " ~ now.w3cDate() , order:'eventDate'}) %}
      {% if events %}
          {% for entry in events %}                
              <option value="{{ entry.eventDate.format('D j M') }},{{ entry.eventName }}">{{ entry.eventDate.format('D j M') }},{{ entry.eventName }}</option>
          {% endfor %}
      {% endif %}
  </select>            
  </label>
  
  ```
  
  **Tags:** form
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2016-03-09. Score: 0 | Accepted answer
  
  As there was no simple answer that didn't require another plugin or javascript I revised my entry form to collect the date manually. Which is a bit of a pain, as the input format for the date has to be mm/dd/yyyy, which isn't normal in the UK.
  
  > **Comments:**
  > **username_1**: Don't picture the Preparse plugin as "yet another plugin". It's a tool that actually should be part of every Craft install, so useful.  
  > **username_0**: I'm coming from ExpressionEngine, and have been bitten by addons that are no longer supported and not updated, and so now I can't update the EE version. I don't want that to happen again. Part of Craft's attraction is that almost everything I want is part of the core so updating isn't a problem.  
  > **username_1**: Have a look at all the maintainers: https://github.com/aelvan/Preparse-Field-Craft/commits/master. Brandon is a one of them and he's a big fan of that plugin. It's here to stay, even if Andre should remove it from GitHub, I bet there will be a replacement plugin within a few days.  
  
  ---
  
  ### Answer by username_2 on 2016-03-02. Score: 2
  
  You could use the [Preparse plugin](https://github.com/aelvan/Preparse-Field-Craft) to create a field that is automatically updated with the `eventDate` value whenever the entry is saved. It wouldn't be a datetime field, but if you stored the *timestamp* (i.e. `{{ dateString|date('U') }}`) it'd be easy to *use* as such.
  
  Another option is to have an hidden input in your form for the `eventDate` datetime field, and use JavaScript to set its value whenever the `<select>` input changes (i.e. listen for the `change` event for the latter, in your JS).
  
  The third option would be to write a plugin which listens to the `entries.beforeSaveEntry` event in order to set the `eventDate` value from the dropdown field.
  
  > **Comments:**
  > **username_1**: Auto Expire plugin allows to copy to a Date/Time field.  
  
  ---
  
  