BourneShady
BourneShady

Reputation: 935

Conversion of html textarea to laravel 4.2 textarea

Hi im using ckeditor so i currently have the html version which is

<textarea class="ckeditor" name="editor" id = "stuff">

        {{ $opendoc }}

    </textarea>

the $opendoc came from my controller. it contains txt in my controller it looks like this

$fname = $file->filename;

    $opendoc = file_get_contents(public_path('uploads/docs/' . $fname));

    return View::make('dmy.open_doc' , compact('title', 'smpl' , 'opendoc'));

im trying to display the data using laravel 4.2 textarea currently im using something like this

{{ Form::textarea('open_file', $opendoc , array('class' => 'ckeditor')) }}

but the value of $opendoccould not be viewed. any ideas what im doing wrong? thanks in advance

Upvotes: 1

Views: 640

Answers (2)

Ashish Chaturvedi
Ashish Chaturvedi

Reputation: 1379

Use the Form::textarea() method.

The simplest usage is to only pass a single argument, the name.

{{ Form::textarea('notes') }}

This produces the following HTML.

<textarea name="notes" cols="50" rows="10"></textarea>

Notice the default cols and rows.

You can pass the value as the second argument.

{{ Form::textarea('notes', '3 < 4') }}

The value will be escaped.

<textarea name="notes" cols="50" rows="10">3 &lt; 4</textarea>

Additional options can be passed as a third argument. This must be an array.

{{ Form::textarea('notes', null, ['class' => 'field']) }}

This will add the class "field" to the text area.

Your solution

{!! Form::textarea('open_file', isset($opendoc)? $opendoc:null, array('class' => 'ckeditor','size' => '10x3')) !!}

Upvotes: 0

Ashly
Ashly

Reputation: 521

It just shows the textarea but without any contents - check whether that variable is set or not.

{!! Form::textarea('open_file', isset($opendoc)? $opendoc:null, array('class' => 'ckeditor','size' => '10x3')) !!}

Upvotes: 1

Related Questions