SAM
SAM

Reputation: 133

<textarea> can't post values in laravel

Hi I'm new to laravel and I create a form then when I tried to post values with textarea it didn't work and this is my code for form:

<form class="form-vertical" role="form" method="post" id="contactForm" action="{{route('newPage')}}">
  <div class="col-lg-12 col-md-12 col-sm-12" data-aos="zoom-in">
    <div class="form-group ">
        <label for="username" class="control-label">موضوع:</label>
        <input type="text" name="title" class="form-control" id="username"
        value="{{ Request::old('title') ?: ''}}">
        @if ($errors->has('title'))
          <span class="help-block">وارد کردن موضوع ضروری است</span>
        @endif
    </div>
  </div>
  <div class="clearfix"></div>

  <div class="col-lg-12 col-md-12 col-sm-12" data-aos="zoom-in">
    <div class="form-group ">
        <label for="contents" class="control-label">سرفصل مربوطه به انگلیسی:</label>
        <input type="text" name="related_subject" class="form-control" id="username"
        value="{{ Request::old('related_subject') ?: ''}}">

        @if ($errors->has('related_subject'))
          <span class="help-block"> وارد کردن سرفصل ضروری است</span>
        @endif
    </div>
  </div>
  <div class="clearfix"></div>

  <div class="col-lg-12 col-md-12 col-sm-12" data-aos="zoom-in">
    <div class="form-group ">
        <label for="contents" class="control-label">شرح مطلب:</label>

        <textarea type="text" rows="10" cols="100" name="contents"
           class=
          "form-control" id="message" style="resize:none"></textarea>

        @if ($errors->has('contents'))
          <span class="help-block"> وارد کردن سرفصل ضروری است</span>
        @endif
    </div>
  </div>
  <div class="clearfix"></div>

  <div class="col-lg-12" data-aos="zoom-in">
    <div class="form-group">
        <button type="submit" class="btn btn-primary">Sign up</button>
    </div>
  </div>
  <div class="clearfix"></div>
        <input type="hidden" name="_token" value="{{Session::token()}}">
    </form>

but it works when I use input instead of textarea! I mean when I deleted text area and use an input it works correctly! How can I solve it?

Upvotes: 2

Views: 3181

Answers (2)

Quy Le
Quy Le

Reputation: 2379

I think you have submitted form use javascript with form's id.
So you should add [form] attribute that same id of form to textarea.

example:
<form name="frmA" id="frmA" action="/" method="post">
 <textarea form="frmA"></textarea>
</form>

Upvotes: 1

Zaheer Ahmad
Zaheer Ahmad

Reputation: 176

You have issue in your textarea syntax

your code

<textarea type="text" rows="10" cols="100" name="contents"
       class=
      "form-control" id="message" style="resize:none"></textarea>

normal code for textarea

<textarea rows="10" cols="100" name="contents"
       class=
      "form-control" id="message" style="resize:none"></textarea>

textarea has no type for more detail you can visit

-W3School html textarea section give you more detail

Upvotes: 1

Related Questions