Answers.Body: <p>The contact form controller creates a <a href="https://github.com/craftcms/contact-form/blob/v2/src/models/Submission.php" rel="nofollow noreferrer"><code>Submission</code> model</a> with the submitted values and provides it to the template as a <code>message</code> variable. You should be able to access this variable inside your template like this:</p>
  <pre class="lang-twig prettyprint-override"><code>{% set message = message ?? null %}
  </code></pre>
  <p>This message will contain the native properties (e.g. <code>fromName</code>, <code>fromEmail</code>):</p>
  <pre class="lang-twig prettyprint-override"><code>{{ message.fromName }}
  {{ message.fromEmail }}
  </code></pre>
  <p>If you use a single textarea field for the message body (<code>name=&quot;message&quot;</code>), the value will be available as <code>message.message</code>:</p>
  <pre class="lang-twig prettyprint-override"><code>{{ message.message }}
  </code></pre>
  <p>If you use multiple custom fields (<code>message[body]</code>, <code>message[phoneNumber]</code>), <code>message.message</code> will be an array with those fields:</p>
  <pre class="lang-twig prettyprint-override"><code>{{ message.message.body }}
  {{ message.message.phoneNumber }}
  </code></pre>
  <p>One notable caveat is that if you're inside an included template that is included with the option <code>with_context = false</code>, the <code>message</code> variable will <em>not</em> be available. In this case, you have to go through the route manager to access it:</p>
  <pre class="lang-twig prettyprint-override"><code>{% set routeParams = craft.app.getUrlManager().getRouteParams() %}
  {% set message = routeParams.message ?? null %}
  </code></pre>
  <p>Note that this applies to contact form plugin version &lt;=3.0.0. For 3.0.0 and above, the variable has been renamed to <code>submission</code>, see the <a href="https://github.com/craftcms/contact-form/blob/main/CHANGELOG.md#300---2022-05-02" rel="nofollow noreferrer">changelog</a> for details.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-03T20:04:38.093Z
Answers.Text: Thank you very much, it works as I wanted.
Answers.UserDisplayName: Kota.M
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-03T08:28:43.360Z
Answers.LastActivityDate: 2022-08-03T08:28:43.360Z
Answers.UserDisplayName: MoritzLost
Body: <p>I have been looking for how to retrieve the inserted values when the submission is failed. Other than prepared fields (Name, Email, etc.), the inserted values disappear from the fields.</p>
  <p>I already found this post, but those solutions did not work for me.
  <a href="https://craftcms.stackexchange.com/questions/2629/p-t-contactform-retrieving-custom-fields-value-after-submitting-form">P/T ContactForm Retrieving Custom fields Value after submitting form</a></p>
  <p>My Craft is ver 3.7.50, Contact Form plugin is ver 2.5.1.</p>
  
Tags: <craft3><plugin-contactform>
Title: P&T Contact Form Plugin - How to Retrieve the inserted values?
ThreadText: # P&T Contact Form Plugin - How to Retrieve the inserted values?
  
  (Asked by: username_0 on 2022-08-02)
  
  I have been looking for how to retrieve the inserted values when the submission is failed. Other than prepared fields (Name, Email, etc.), the inserted values disappear from the fields.
  
  I already found this post, but those solutions did not work for me.
  [P/T ContactForm Retrieving Custom fields Value after submitting form](https://craftcms.stackexchange.com/questions/2629/p-t-contactform-retrieving-custom-fields-value-after-submitting-form)
  
  My Craft is ver 3.7.50, Contact Form plugin is ver 2.5.1.
  
  **Tags:** craft3, plugin-contactform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-08-03. Score: 2 | Accepted answer
  
  The contact form controller creates a [`Submission` model](https://github.com/craftcms/contact-form/blob/v2/src/models/Submission.php) with the submitted values and provides it to the template as a `message` variable. You should be able to access this variable inside your template like this:
  
  ```twig
  {% set message = message ?? null %}
  
  ```
  
  This message will contain the native properties (e.g. `fromName`, `fromEmail`):
  
  ```twig
  {{ message.fromName }}
  {{ message.fromEmail }}
  
  ```
  
  If you use a single textarea field for the message body (`name="message"`), the value will be available as `message.message`:
  
  ```twig
  {{ message.message }}
  
  ```
  
  If you use multiple custom fields (`message[body]`, `message[phoneNumber]`), `message.message` will be an array with those fields:
  
  ```twig
  {{ message.message.body }}
  {{ message.message.phoneNumber }}
  
  ```
  
  One notable caveat is that if you're inside an included template that is included with the option `with_context = false`, the `message` variable will *not* be available. In this case, you have to go through the route manager to access it:
  
  ```twig
  {% set routeParams = craft.app.getUrlManager().getRouteParams() %}
  {% set message = routeParams.message ?? null %}
  
  ```
  
  Note that this applies to contact form plugin version <=3.0.0. For 3.0.0 and above, the variable has been renamed to `submission`, see the [changelog](https://github.com/craftcms/contact-form/blob/main/CHANGELOG.md#300---2022-05-02) for details.
  
  > **Comments:**
  > **username_0**: Thank you very much, it works as I wanted.  
  
  ---
  
  