yii2: Show label instead of value for boolean checkbox

前端 未结 3 1705
灰色年华
灰色年华 2021-01-04 20:03

I have created a check-box input as type Boolean for storing values as dishcharged - checked or unchecked. Checked will store 1 and unchecked will store 0.

Now I wan

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 20:47

    If you consistently display booleans the same way in your app, you can also define a global boolean formatter:

    $config = [
            'formatter' => [
              'class' => 'yii\i18n\Formatter',
              'booleanFormat' => [' no', ' Yes'],
            ],
        ];
    

    Then add your column:

    'discharged:boolean',
    

提交回复
热议问题