Adding php sprintf function to format value in Gridveiw

I am trying to add leading zeros to a number to be shown in Gridview. I am trying this code, but it is throwing error like:

Getting unknown property: app\models\OpdTestBill::0000

The code I am using is like this:






What is the proper syntax to achieve this?



[ 'attribute'=>'dhanwantri_bill_number',



Here too I am getting the error:

Unknown format type: 0000  

throw new InvalidParamException("Unknown format type: $format")

The top one is what it should be.

It needs the format raw part



Value=>function ($model) {

return sprintf('%04d',$model->dhanwantri_bill_number);