5

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

lakru-one
  • 139
  • 8

2 Answers2

3

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

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.

MAZ
  • 864
  • 11
  • 19