phpyiicgridviewyii1.x

How to write this html part in CGridView Yii1.1


This is the column(It is a numerical input with range of numbers between 1 and 60), that I want to add into CGridView, but I want to append terminalcode to the id of this input. In this code everything is working properly, but terminalcode is not appending with id.

   array(
            'header' => 'Validity',
            'name' => 'validity',
            'value' => function(){ return '<input type="number" id="tentacles".$data["terminalcode"] name="tentacles" min="1" max="60">';},
            'type' => 'raw'
    )


Solution

  • You need to adjust your return value and add $data parameter in value function. Your code would become like this

    array(
        'header' => 'Validity',
        'name' => 'validity',
        'value' => function($data){ return '<input type="number" id="tentacles'.$data["terminalcode"].'" name="tentacles" min="1" max="60">';},
        'type' => 'raw'
    ),
    

    I hope your problem will be solved.