yii framework - CLinkColumn passing values to javascript - yii-events

I'm new to YII framework, I wanted to create a link column having a image. Clicking image should call a Javascript function, PHP values need to be passed to that javascript function. here is the code,
<pre>
array(
'class'=>'CLinkColumn',
'header'=> 'Trades',
'imageUrl' => '/images/view_all.png',
'htmlOptions'=>array('style'=>'text-align:justify'),
'linkHtmlOptions'=>array("id"=>'$data["id"]','onclick'=>'viewTrades($data["id"])')
),
</pre>
But the HTML is not getting rendered properly. It is getting printed wrongly as,
<pre>
</pre>
Instead i wanted this to be printed as ,
<img alt="Link" src="/images/view_all.png">
Any help is highly appreciated!!!

I figured it out by myself, here is the code. Hope it might be useful for someone!
'name'=>'trades',
'value'=>'CHtml::link("View",array("view", "id"=>$data["id"]), array("id"=>$data["id"], "class"=>"linkClass", "onclick"=>"viewTrades($data[id]); "))',
'type'=>'raw',
),

Related

Escaping raw html in blade template files

i hope you're having a good day.
i have some raw html that i want to render inside my blade file,
ive tried the {!!...!!} syntax but for some reason it is not working for me, when i use this
{ !! $jobs[0]->content !!}
i get this result
My laravel version is >8.
Thank you for your answer.
The syntax is without the space. Removing your leading space will solve your issue.
{!! $jobs[0]->content !!}
https://laravel.com/docs/8.x/blade#displaying-unescaped-data

Why isn't my view redirecting to a controller?

I have a html form inside one of my views that is supposed to get an image the user uploads and save it, the form is below:
<form class="col-lg-12" action="/banner/store/">
The form itself is quite large, but later on there's a to end it. It was supposed to redirect me to the banner/store where my Banner controller have a dd() function so I can confirm everything is okay. But instead, I get a blank white screen and the url goes banner/store/?.
The routes to the BannerController seems to be correct since banner/create works, the problem is when I go from create to store, but anyways, here's how I set the Routes:
Route::resource('banner', 'BannerController');
Any ideas why my banner/store won't work? And why is there a question mark on the end of the url? Sorry if this may be a dumb error, I'm still learning coding.
Your action is is wrong. When you use the resource static method then the store-url is the same as the GET url.
You can achive your goal with:
<form class="col-lg-12" action="{{ route('banner.store') }}" method="POST">
See more information in documentation.
When you updating your banner, you can't use the browser native form with PUT.
See in this document how laravel will handle that for you.

Why does the content is not same from ckeditor to html page?

Hi everyone i got problem fetching the correct format data that i insert in the database from ckeditor. so in this case when i fetch the data from the database, the format that i make in ckeditor is not same in the html page. so to understand well, i will demonstrate what I am saying.
Programming Language: Laravel
1. Illustration (listing number)
2. Inserted data in the database .
3. Output
Foreach Code:
#foreach($bump_bar_not_working_solution as $bump_bar_not_working_solution_data)
<label style="font-size:14px;">{{strip_tags($bump_bar_not_working_solution_data->description)}}</label>
#endforeach
Import CKeditor:
<script src="https://cdn.ckeditor.com/ckeditor5/16.0.0/classic/ckeditor.js"></script>
Hope Someone experience this.
For laravel 5 you can use this code
{!!html_entity_decode($text)!!}
you can check this [link]: Laravel 5: Display HTML with Blade
Using this escape tags my problem is solved. ({!! !!}).
https://laravel.com/docs/master/blade#displaying-data
Thanks Rwd

Trumbowyg: Can't get the textarea value in PHP

I'm trying to use a WYSIWYG editor in my Laravel application but I have a bug I can't solve.
What works:
A form that sends a post request with a text area filled (name = pitch)
So the request is well formed and I can retrieve it in my controller, everything is perfect
My Problem
When I add a WYSIWYG editor on this specific textarea (with Trumbowyg or Redactor, I tried both), then pitch disappears from the request and I can't get it on the controller.
I don't have any JS issue in the console, when I delete the call to the WYSIWYG editor, everything is fine, so I don't know where to search.
DB field for pitch is text (I tried switching it to string, but didn't work either).
Here is my view code:
<tr>
<td>{!! Form::label('pitch', 'Pitch') !!}</td>
<td>{!! Form::textarea('pitch','',array('class' => 'pitch')) !!}</td>
</tr>
<script type="text/javascript">
$(function()
{
$('#pitch').trumbowyg({
resetCss: true
});
});
</script>
And in the Controller, this code gives me null
dd($request->input('pitch'));
Mode Code Sample in this gist
Actually, a friend of mine helped me to catch the problem.
Thank you very much #Chris & # haakym
So the problem is an HTML conflict, my form was imbricated in a table and that made a parsing conflit so i put the begining and the closing of the form outside of the table and now it's fine.
I would certainly never have found that by myself because everything else was working fine, but you know that's what they call experience !

EmberJs ember-animated-outlet not working

I'm trying to use ember animated outlet (found here) and, I can not for the life of me get it to work, I understand that instead of using {{outlet}} I need to use {{animated-outlet}} and use {{link-to-aniamted}} instead but it seems to be switching like normal. I also know that I need to include the js after the ember.js and also I am including the css file it comes with, so I'm kind of stumped on this. :(
For my basic view, I'm using
<script type="text/x-handlebars" data-template-name="application">
<div class='wrapper'>
#include('includes.globals.header')
<div class='content row' id='content'>
{{animated-outlet}}
</div>
#include('includes.globals.footer')
#include('includes.js.navigation')
</div>
</script>
and my link looks like:
{{#link-to-animated 'index' animations="main:slideLeft"}} Home #{{/link-to-animated}}
So, is there something i'm missing? Do I need to add something in my app.js? IF you need more code or info, just ask and I will edit this question! Thanks a lot in advance! I'm new to ember, so please take it easy!
You need to specify 'name' in the animated-outlet helper.
{{animated-outlet name="main"}}
The readme explains it: https://github.com/billysbilling/ember-animated-outlet/blob/master/README.md#use-animated-outlet-instead-of-outlet

Resources