I am using Yii::$app->formatter
in one of my attribute like:
Controller code
$model->discharge_date=Yii::$app->formatter->asDatetime
($model->discharge_date, 'php:d-M-Y H:i');
Model Code
[['admission_date','discharge_date'],'date','format' => 'php:d-M-Y H:i'],
Everything is working fine except when discharge date is left blank, on update it is filled with this line:
<span class="not-set">(not set)</span>
I couldn't make out from where this is coming, as in the DB the value is NUll
Thanks.
It's default and expected behavior.
See documentation for $nullDisplay property of Formatter.
You can cnahge that across application through application configuration:
'formatter' => [
'nullDisplay' => '',
],
For specific view you can change it through formatter component (note that you should add that code before view is rendered):
use Yii;
...
Yii::$app->formatter->nullDisplay = '';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With