如何在CakePHP中使表单字段成为超链接?

时间:2011-11-17 08:48:49

标签: php cakephp cakephp-1.3 cakephp-2.0

我有一个选项数组:

$allAmazonMatches = Array ( [1] => B002I0HJZO [2] => B002I0HJzz [3] => B002I0HJccccccccc )

我使用表单助手显示它们:

<?php
echo $this->Form->create('AmazonMatches', array('action' => 'selectMatches'));
echo $this->Form->input('option_id', array('options' => $allAmazonMatches, 'type' => 'radio'));
echo $this->Form->end(__('Submit', true));
?>

我想表现的是:

option1       http://somewebsite/B002I0HJZO (hyper link that opens in new tab)
option2       http://somewebsite/B002I0HJzz (hyper link that opens in new tab)

如何设置我的选项数组的样式?

2 个答案:

答案 0 :(得分:0)

你有没有试过这样的事情:

$label1 = $this->Html->link('blabla1', 'http://www.google.de', array('target' => '_blank'));
$label2 = $this->Html->link('blabla2', 'http://www.google.de', array('target' => '_blank'));

$options = array(0 => $label1, 1 => $label2);

echo $this->Form->input('accept', array('type' => 'radio', 'options' => $options));

答案 1 :(得分:0)

你可以做到,但我不确定这是推荐做法。点击标签应该真正检查收音机 - 但如果你真的必须:

    $allAmazonMatches = array(
      'B002I0HJZO' => '<a href="http://somewebsite/B002I0HJZO">http://somewebsite/B002I0HJZO</a>',
      'B002I0HJzz' => '<a href="http://somewebsite/B002I0HJZO">http://somewebsite/B002I0HJzz</a>',
      'B002I0HJccccccccc' => '<a href="http://somewebsite/B002I0HJZO">http://somewebsite/B002I0HJccccccccc</a>'
    );