Ramzan Mahmood
Ramzan Mahmood

Reputation: 1901

Getting raw HTML Textarea within other rextarea (laravel 5.3)

I am getting raw html from my controller and getting it into textarea. there is different type of fields as text select or also can be textarea which will be print in textbox as raw html. its working fine for all fields except textarea.

when there is a field include with textarea type then below buttons string code not comes in text box and code of textarea type shows but without ending tag as

here is my code.

 foreach($fields as $field){
    $type = $field->type;
switch($type) {
   case 'textarea':
    $str .=    '<div class="form-group">
                    <label class="control-label col-md-3">'.$custom_field->name.'
                    </label>
                    <div class="col-md-8">
                        <div class="input-icon right">
                            <i class="fa"></i>
                            <textarea name="'.$field->id.'" class="form-control" rows="8"></textarea>
                        </div>
                    </div>
                </div>';
            break;
      }
}

Now every thing works fine except when textarea type included. problem is if there is textarea type then below buttons not appear and also not ending tag of textarea

this end of html out put is as without buttons sting and without endtag

`<div class="form-group">
                        <label class="control-label col-md-3">Description
                        </label>
                        <div class="col-md-8">
                            <div class="input-icon right">
                                <i class="fa"></i>
                                <textarea name="17" class="form-control" rows="8">`

please help where its wrong

Upvotes: 1

Views: 625

Answers (1)

Autista_z
Autista_z

Reputation: 2541

You just replace < with &lt; and > with &gt;

Everything else is OK.

Just edit your case to:

case 'textarea':
$str .=    '<div class="form-group">
                <label class="control-label col-md-3">'.$custom_field->name.'
                </label>
                <div class="col-md-8">
                    <div class="input-icon right">
                        <i class="fa"></i>
                        <textarea name="'.$field->id.'" class="form-control" rows="8">&lt;/textarea&gt;
                    </div>
                </div>
            </div>';
        break;

Upvotes: 1

Related Questions