1

私はdropdownこのようなリストを持っています

   <?php echo $form->dropdownList($customers,'customer_name', CHtml::listData(Customers::model()->findAll(), 'id', 'customer_name'),
 array(
   'ajax'=> array(
             'type'=>'GET',
             'url'=>
             'data'=>
           ),
             'empty'=>--Select One---')); ?>

を作成するための別のリンクnew customerは次のようなものです

 <?php echo CHtml::link('Create Customers', "",array(
        'style'=>'cursor: pointer; text-decoration: underline;',
        'onclick'=>"{addCustomers(); $('#dialogCustomers').dialog('open');}"));?>

create customer link中に入れる必要がありますdropdown list。配置方法create customer link inside the dropdown list、両方のリンクをマージして単一のリンクに作成する方法は?

4

2 に答える 2

1

あなたが何をしようとしているのかよくわかりませんが、私が得たものから、次のようなものが必要です:

echo $form->dropDownList(
    $customers,
    'customer_name',
    CMap::mergeArray(
        CHtml::listData(
            Customers::model()->findAll(), 'id', 'customer_name'
        ),
        array(
            'create_customer_link'=>'Create new customer'
        )
    ),
    array(
        'empty'=>array('Select'=>'--Select One---'),
        'id'=>'Customers_name',
        'ajax'=> array(
            'type'=>'GET',
            'beforeSend'=>'js:function(){
                if($("#Customers_name").val() == "create_customer_link") {
                    addCustomers();
                    $("#dialogCustomers").dialog("open");
                    return false;
                }
            }',
            'url'=>...
            'data'=>...
        ),
        'options'=>array(
            'create_customer_link' => array('class'=>'my_custom_css_class'),
            // ... etc. You can add any html option here.
            // check http://www.yiiframework.com/doc/api/1.1/CHtml#dropDownList-detail for more info
        )
    )
);
于 2012-04-07T02:50:30.913 に答える
0

あなたの要求を理解できれば。ドロップダウン リストのオプションにリンクを追加します。これはこれを行う簡単な方法です。

                    <?php 
                      echo CHtml::dropDownList('city_name', null,
                        $arrPopularCities, 
                        array(
                            'prompt' => 'Popular City',
                            'class' => 'btn btn-default btn-dropdown dropdown-toggle',
                            'style' => 'border-right:2px solid #4bacc6;',
                        )); 
                ?>

以下のjqueryを追加

    $('#city_name').change(function() {
    if($(this).val() != ""){
        window.location.assign('<?php echo Yii::app()->createUrl('city/view'); ?>' + '?id=' + $(this).val());
    }
});
于 2015-05-29T11:18:29.733 に答える