How to write this html part in CGridView Yii1.1

258 Views Asked by At

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'
    )

2

There are 2 best solutions below

1
MAZ On BEST ANSWER

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.

0
Widuranga Dilruksha On

You can change your code like this.

array(
            'header' => 'Validity',
            'name' => 'validity',
            'value' => 'CHtml::textField ("", "", array ("id"=>"tentacles".$data["terminalinfoid"], "style" =>"width:40px", "maxlength"=>"4"));',
            'type' => 'raw'
                             )
        ),