Search code examples
laravellaravel-5.5laravel-5.6laravel-bladelaravelcollective

Text Area and Null, Laravel Collective


I've been using Laravel Collective for my forms and I seem to have encountered an issue with textareas. One that won't let me update null textarea fields with the same code I would use for a text field. I think the issue is with 'null' as it allows me to change the field if the textarea has text loaded. Does anyone know how to fix this so I can change null fields with textareas?

{!! Form::label ('otherinfo', 'Other information:') !!}
{!! Form::textarea ('otherinfo', null, array('class' => 'form-control', 'required' => '', 'maxlength' =>'1500') ) !!}

Solution

  • Your example should work fine. Make sure you update your Controller to accept and save the value that is present in $request->input('otherinfo').

    <?php
        $otherinfo = 'Hello World';
    ?>
    
    <div class="form-group">
        {!! Form::label('otherinfo', 'Other information:') !!}
        {!! Form::textarea('otherinfo', $otherinfo, ['class' => 'form-control', 'size' => '50x3']) !!}
    </div>