<p>I recommend the tutorial <a href="https://craftquest.io/courses/how-to-create-craft-plugin" rel="nofollow noreferrer">https://craftquest.io/courses/how-to-create-craft-plugin</a> Now, It is free after registration. After 1/2h you have your own plugin with settings and form with controller. Simple, straightforward, with craft form component. Your code is quite messy, try tutorial.</p>

CC BY-SA 4.0
2018-11-12T17:21:25.817Z
2018-11-12T23:04:46.803Z
2018-11-12T23:04:46.803Z
lenka
<p>I am trying to learn Craft and since I don't know how to create a form with one text area and a button. On the button press, I want to redirect to another html found in the template directory, I am messing around with Craft's contact form to get the desired functionality. I had this code which was working fine:</p>

<pre><code>{% macro errorList(errors) %}
    {% if errors %}
        &lt;ul class="errors"&gt;
            {% for error in errors %}
                &lt;li&gt;{{ error }}&lt;/li&gt;
            {% endfor %}
        &lt;/ul&gt;
    {% endif %}
{% endmacro %}

{% from _self import errorList %}

&lt;form method="post" action="" accept-charset="UTF-8"&gt;
    {{ csrfInput() }}
    &lt;input type="hidden" name="action" value="contact-form/send"&gt;
    {{ redirectInput('contact/thanks.html?from={fromName}') }}

    &lt;h3&gt;&lt;label for="from-name"&gt;Your Name&lt;/label&gt;&lt;/h3&gt;
    &lt;input id="from-name" type="text" name="fromName" value="{{ message.fromName ?? '' }}"&gt;
    {{ message is defined and message ? errorList(message.getErrors('fromName')) }}

    &lt;h3&gt;&lt;label for="from-email"&gt;Your Email&lt;/label&gt;&lt;/h3&gt;
    &lt;input id="from-email" type="email" name="fromEmail" value="{{ message.fromEmail ?? '' }}"&gt;
    {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}

    &lt;h3&gt;&lt;label for="subject"&gt;Subject&lt;/label&gt;&lt;/h3&gt;
    &lt;input id="subject" type="text" name="subject" value="{{ message.subject ?? '' }}"&gt;
    {{ message is defined and message ? errorList(message.getErrors('subject')) }}

    &lt;h3&gt;&lt;label for="message"&gt;Message&lt;/label&gt;&lt;/h3&gt;
    &lt;textarea rows="10" cols="40" id="message" name="message"&gt;{{ message.message ?? '' }}&lt;/textarea&gt;
    {{ message is defined and message ? errorList(message.getErrors('message')) }}

    &lt;input type="submit" value="Send"&gt;
&lt;/form&gt;
</code></pre>

<p>What I did to only have one textbox and a button, I removed a lot of code:</p>

<pre><code>&lt;form method="post" action="" accept-charset="UTF-8"&gt;
    {{ csrfInput() }}
    &lt;input type="hidden" name="action" value="contact-form/send"&gt;
    {{ redirectInput('contact/thanks.html?from={fromName}') }}


    &lt;h3&gt;&lt;label for="from-email"&gt;From&lt;/label&gt;&lt;/h3&gt;
    &lt;input id="from-name" type="text" name="fromName" value="{{ message.fromName ?? '' }}"&gt;
    &lt;input type="submit" value="Send"&gt;
&lt;/form&gt;
</code></pre>

<p>My thanks.html has the following code:</p>

<pre><code>&lt;p&gt;Thank you {{ craft.app.request.getQueryParam('from') }} will contact you soon&lt;/p&gt;
</code></pre>

<p>Before changing the code, the redirect worked fine and I was getting the 'from' replaced after the 'Thank you'. After I changed the code, on pressing the button the page refreshes but nothing happens and it doesn't get redirected to the thanks.html page. Please help. </p>

<p>Also, kindly direct me to the documentation which tells in detail about front end development in Craft as the official documentation is very vague (or seems vague to me :( )</p>

CC BY-SA 4.0
2018-11-12T17:22:36.643Z
You can ask only one question in one post, so create a new front end question.
lenka
<craft3>
Help needed for a simple form
# Help needed for a simple form

(Asked by: username_0 on 2018-11-10)

I am trying to learn Craft and since I don't know how to create a form with one text area and a button. On the button press, I want to redirect to another html found in the template directory, I am messing around with Craft's contact form to get the desired functionality. I had this code which was working fine:
{% macro errorList(errors) %}
    {% if errors %}
        
            {% for error in errors %}
                {{ error }}
            {% endfor %}
        
    {% endif %}
{% endmacro %}

{% from _self import errorList %}


    {{ csrfInput() }}
    
    {{ redirectInput('contact/thanks.html?from={fromName}') }}

    Your Name
    
    {{ message is defined and message ? errorList(message.getErrors('fromName')) }}

    Your Email
    
    {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}

    Subject
    
    {{ message is defined and message ? errorList(message.getErrors('subject')) }}

    Message
    {{ message.message ?? '' }}
    {{ message is defined and message ? errorList(message.getErrors('message')) }}

    


What I did to only have one textbox and a button, I removed a lot of code:

    {{ csrfInput() }}
    
    {{ redirectInput('contact/thanks.html?from={fromName}') }}


    From
    
    


My thanks.html has the following code:
Thank you {{ craft.app.request.getQueryParam('from') }} will contact you soon

Before changing the code, the redirect worked fine and I was getting the 'from' replaced after the 'Thank you'. After I changed the code, on pressing the button the page refreshes but nothing happens and it doesn't get redirected to the thanks.html page. Please help. 
Also, kindly direct me to the documentation which tells in detail about front end development in Craft as the official documentation is very vague (or seems vague to me :( )

**Tags:** craft3
> **Comments:**
> **username_1**: You can ask only one question in one post, so create a new front end question.  

---

## 1 answers

### Answer by username_1 on 2018-11-12. Score: 1

I recommend the tutorial <https://craftquest.io/courses/how-to-create-craft-plugin> Now, It is free after registration. After 1/2h you have your own plugin with settings and form with controller. Simple, straightforward, with craft form component. Your code is quite messy, try tutorial.


---

