PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, March 3, 2022

[FIXED] YII - Add another attribute to dropDownList

 March 03, 2022     php, yii     No comments   

Issue

I will to add another attribute to dropDownList.

I will a dropdown list like this with Yii dropDownList:

<select name="city" id="city">
    <option value="1" test="123">one</option>
    <option value="2" test="234">two</option>
    <option value="3" test="345">three</option>
    <option value="4" test="456">four</option>
</select>

I will add test attribute to option tags.

Default Yii dropDownList is:

<?php 

echo CHtml::activeDropDownList('City', 'City', array(1 => 'one', 2 => 'two')); 

?>

How I can do this?


Solution

Try :

<?php 
echo CHtml::dropDownList(
    'City',
    'City',
    array(1 => 'one', 2 => 'two'),
    array('options' => array(
        '1' => array('test' => '123'),
        '2' => array('test' => '234'),
    ))
);
?>


Answered By - Ororuk
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing