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:


[

'attribute'=>'dhanwantri_bill_number',

'format'=>'raw',

'value'=>sprintf('%04d','dhanwantri_bill_number')

],

What is the proper syntax to achieve this?

Thanks.

Variation


[ 'attribute'=>'dhanwantri_bill_number',

   'format'=>sprintf('%04d','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’=>sprintf(’%04d’,$model->dhanwantri_bill_number)

Or

Value=>function ($model) {

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

}