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

search for multiple keywords in the same field in Yii2
What is function behaviors in SiteController.php?
In YII2 validation rules I need something opposite to compare
How to add sendgrid mailer function in yii2?
Yii2 dataprovider- exclude first 2 elements
Many to many relationships in Yii2
yii2 swiftmailer link does not work
Call to a member function saveAs() on null (I can not update if I do not select an image)
yii2 dataProvider- offset in dataprovider doesn't work [duplicate]
Yii2 Active Record get the latest record
how to show json formated data in GridView
How to convert HTML page to image in yii2
Does Yii2 take care of the important security concerns?
Swift_IoException Unable to open file for reading yii2
Yii2 change the theming for just one view file
Trying to get property of non-object in action column in yii2

Categories

HOME
testing
multithreading
bluetooth
amazon-ec2
fluentd
push-notification
cplex
jira
leon
umd
icloud
baqend
pivotal-cloud-foundry
awesome-wm
tomcat6
kentor-authservices
wheelnav.js
etl
correlation
php-7.1
caml
google-static-maps
propel
interop
contextmenu
emulator
paging
riot.js
core-text
fish
status
uninstall
assistant
subdomains
delicious-api
bpel
gsoap
fog
mpmediaquery
sequential
picasso
disassembling
jquery-bootgrid
web-mining
code-search-engine
lumberjack
android-mediaprojection
midl
businessworks
pango
pubmed
alphabet
return-value
nstextview
worker-thread
google-perftools
pillow
spring-cache
yt-project
root-framework
medium.com
firmata
passport-google-oauth
xml-attribute
connect-by
ios4
tform
kendonumerictextbox
pervasive-sql
spim
xna-4.0
msys
teamcity-8.0
createprocessasuser
ami
apache-commons-net
kineticjs
typekit
ceil
starcluster
bundles
apc
ruby-datamapper
bulkloader
ora-00911
buster.js
seed
orchardcms-1.7
angularjs-controller
broken-links
errai
viewswitcher
online-compilation
chrono
heartbeat
blitz++
.nettiers
exchange-server-2003
ctp4
mtj
eqatec
avatar
commodore
ajax-forms

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App