Laravel: textarea does not refill when using Input::old

前端 未结 5 500
感情败类
感情败类 2021-02-07 17:39

I am experiencing that only the Input Textfields respond as expected when I write the code to repopulate a form (when errors were found for example) or when from a table row I c

相关标签:
5条回答
  • 2021-02-07 18:09

    textarea does not have a value attribute. Values in textarea should be inside <textarea></textarea>, so in your case:

    <textarea id="message" name = "content" rows="10" cols="50" onKeyPress class="form-control">
    {{{ Input::old('content') }}}
    </textarea>
    
    0 讨论(0)
  • 2021-02-07 18:11

    Just figured it out, put the old value in between the brackets as below

    <textarea name="message">{{ old('message') }}</textarea>

    0 讨论(0)
  • 2021-02-07 18:17

    Sorry for late reply

    {{Form::textarea('mobile_message', isset($notifications -> mobile_message) ? $notifications -> mobile_message : null, 'id'=> 'mob_id','class' => 'form-control'))}}
    
    0 讨论(0)
  • 2021-02-07 18:23

    This is another way to do the same but with the Forms component from laravel:

    {{ Form::textarea('content',Input::old('content'),array('id' => 'message')) }}
    
    0 讨论(0)
  • 2021-02-07 18:30

    I'd like to add one thing, if you use Form Class for the form and elements then you don't need to explicitly right the Input::old('element-name') to retrieve the value of the previous form submission.
    Just use
    {{ Form::text('name', null, array('id'=>'name', 'class' => 'class-to-apply')) }}
    And you're good to go.

    Here, null value for the text field will be null for the first time, and if you redirect back this page with input then this will automatically grab the value.

    0 讨论(0)
提交回复
热议问题