yii2


Object of class Closure could not be converted to string


I have got this error while using the code below in DetailView of Yii 2.
Object of class Closure could not be converted to string
The code is:
[
'format' => 'raw',
'attribute' => 'title',
'value' => function($model1, $key) {
if ($model1->book->language == 1) {
$m = "<p class='n'>" . $model1->book->title . "</p>";
} else {
$m = $model1->book->title;
}
return $m;
},
'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center']
],
Can you guys help me?
DetailView does not take closure like GridView for value, just string. Change it to:
'value' => $model1->book->language == 1
? "<p class='n'>" . $model1->book->title . "</p>"
: $model1->book->title,

Related Links

Yii2 Gii : You are not allowed to access this page
Yii2: Signup page shows error “403 forbidden you are not allowed to access the page”
Yii2 include assets after code generated by widget
Yii2: Adding menubar specific content to menubar on specific page load
How to access module's model in yii2
ArrayDataProvider with CGridView pagination Yii2
Yii framework 2.0 pass parameter to eager loading relational database table
Which folder to add custom helper functions to in Yii
Yii2: Assigning javascript event to anchor tag in yii2
Hide Yii2 GridView Action buttons
Yii2 query condition with exists
Retrieving array of Controllers/Actions
How to change label text of the ActiveField?
download files using Yii2 gridFS
Yii2:Does login,signup & password reset forms work together in single view
Yii2: How to add textarea in yii2

Categories

HOME
pandas
minimum-spanning-tree
view
fft
electron
frameworks
portia
append
slick-slider
percona
jsprit
caml
serverless-framework
reactcsstransitiongroup
contextmenu
crystal-reports-2008
jquery-ajaxq
intentfilter
language-agnostic
mmap
cas
info.plist
windows-error-reporting
applozic
msys2
dbclient
jaxb2
nouislider
airconsole
karaf
google-sites-2016
lxd
azure-sql-database
y86
sequential
swisscomdev
user-controls
trim
grid.mvc
node-gyp
node-sass
thin
convertapi
jxcore
diagnostics
android-cursor
dynamics-sl
redundancy
minimization
blacklist
firmata
savon
login-control
asp.net-4.5
nsfilemanager
paypal-express
plottable.js
fputcsv
connect-by
lua-5.1
prettytensor
python-stackless
ipconfig
photobucket
freelancer.com-api
django-unittest
emailrelay
twirl
php-ci
jsapi
jsonpickle
ng-animate
terminfo
dml
wp-query
xceed-datagrid
bundles
mbr
oam
aqtime
hungarian-algorithm
pushbackinputstream
jquery-mobile-dialog
lcs
tinn-r
unc
venn-diagram
multipage
dbproviderfactories
regsvr32
chrono
subscript
xmemcached
horizontal-accordion
locationlistener
visitor-statistic
yslow
bespin
libs
ntvdm.exe

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App