0

PHP変数をモーダルウィンドウに渡したいのですが、このリンクを使用してモーダルウィンドウを開いていますが、変数をこのリンクに渡し、モーダルウィンドウで同じ変数を取得したいので、これを実行して追加しようとしています一部のdivのテキストですが、クエリで取得できないhtmlを返します

 echo CHtml::link(
                                'Set Recipe', '', array(
                            'class' => 'testclass',
                            'id' => $finalDate,
                            'data-toggle' => 'modal',
                            'data-target' => '#myModal',
                            'fahadVar' => $finalDate
                        ));

このボタンをクリックすると、モーダルウィンドウが表示されます ボタンに設定された変数を取得する方法 ここに yiibooster の簡単なモーダルコードがあります

     <div class="modal-body">
<p>One fine body...</p>
</div>

<div class="modal-footer">
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'type' => 'primary',
'label' => 'Save changes',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'label' => 'Close',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
</div>

<?php $this->endWidget(); ?>

前もって感謝します

4

1 に答える 1

0

ウィジェットを作成する必要があります。

注:以下は別の投稿からコピーしました。それは魅力のように機能します。

最初に新しいウィジェットを作成します。名前がCategoryWidgetだとしましょう。このウィジェットをコンポーネント ディレクトリ protected/components の下に置きます。

class CategoryWidget extends CWidget {

    public function run() {
        $models = Category::model()->findAll();

        $this->render('category', array(
            'models'=>$models   
        ));
    }
}

次に、このウィジェットのビューを作成します。ファイル名は、category.php です。protected/components/views category.php の下に置きます

<?php if($models != null): ?>
<ul>
    <?php foreach($models as $model): ?>
    <li><?php echo $model->name; ?></li>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

次に、メイン レイアウトからこのウィジェットを呼び出します。main.php // あなたのコード ...

<?php $this->widget('CategoryWidget') ?>
于 2014-11-15T06:11:27.563 に答える