I pass my view a collection. If I output this as an array, I get something like this
array:2 [▼
0 => array:8 [▼
"id" => "53"
"name" => "creativeOption"
"label" => "checkboxSelection"
"value" => "Animated GIF"
"campaignCreativesId" => "21"
"deleted_at" => null
"created_at" => "2016-03-01 13:52:36"
"updated_at" => "2016-03-01 13:52:36"
]
1 => array:8 [▼
"id" => "54"
"name" => "creativeOption"
"label" => "Other"
"value" => "12345"
"campaignCreativesId" => "21"
"deleted_at" => null
"created_at" => "2016-03-01 13:52:36"
"updated_at" => "2016-03-01 13:52:36"
]
]
Basically, I have a few checkbox selections. If the Other checkbox is checked, a text area is displayed to get more details. In my view, I do the following
@foreach($campaign->campaignCreatives->campaignCreativesData as $data)
@if($data->label == 'Other')
{{dd($data->value)}}
<div class="col-md-12 noPadding" id="cOtherText">
{!! Form::textarea('otherInput', $data->value, array('placeholder' => 'Please provide some additional information')) !!}
</div>
@else
<div class="col-md-12 noPadding" id="cOtherText">
{!! Form::textarea('otherInput', null, array('placeholder' => 'TEST')) !!}
</div>
@endif
@endforeach
What I essentially do is check to see if there is a label named Other for this collection. If there is, I want to display the text area with the old input. If there is no label called Other, I just need a blank textarea displayed.
Now with the above, you can see I have placed a dd within the if statement. This is what I am finding strange. With the above array/collection, the if should be used because there is a label called Other present. As I would expect, the dd is fired. The dd outputs "12345" which is the data which was previously added to this textarea. So if I remove this dd, I would expect the textarea to display with 12345 within it.
However, I seem to be displayed the textarea in the else statement. Reason I know that this textarea is being displayed is because I set the placeholder to TEST and this is what I see within the textarea.
So even though the if statement is satisfied, why does it display the second textarea?
Thanks
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1QjR9Dc
via IFTTT
Aucun commentaire:
Enregistrer un commentaire