2011-03-01 22 views
0

我正在開發一個zendframework項目。我的註冊頁面中包含一個字段「我同意使用條款」,附近有一個複選框。在這裏,我想使「使用條款」爲紐帶,但我是新來的Zend和PHP5。我檢查了代碼,並在下面顯示‘我同意使用條款’將HTML放在Zend_Form_Element標籤中

'Agree' => array ('Checkbox', array (

    'Required' => true, 

    'Decorators' => $element Decorators, 

    'Label' => 'I Agree to the Terms of Use', 

)), 
代碼

我怎麼會讓使用條款爲紐帶?

+1

我會建議使用標題,如: 「鏈接一個Zend_Form_Element生成的標籤」 – 2011-03-01 09:43:47

回答

4

您可以添加到HTML標籤,如果你有你的標籤裝飾集首先,將'escape' => false添加到您的標籤修飾器的選項中。確切的裝飾也很難說究竟應該如何看待你,但它很可能是這樣的:

$elementDecorators = array(
    // some decorators... 
    array('Label', 
     array('placement' => 'prepend', 
       'escape' => false)), 
    // other decorators... 
); 

然後,HTML錨點添加到您的標籤:

'Label' => 'I Agree to the <a href="/terms-of-use/">Terms of Use</a>', 

警惕在標籤上放置鏈接。標籤的原生點擊操作是將焦點放在與其關聯的輸入上。如果您遇到問題,可以將相同的選項應用於修飾器Description並在其中添加鏈接。

-1

我不知道這個框架,只是猜測什麼...

'Label' => 'I Agree to the <a href="/terms.pdf">Terms of Use</a>', 
+0

你猜錯了這一次:P的HTML轉義,除非逃生如上所述設置爲false – 2012-04-22 17:00:51

0

你也可以做到這一點通過以下方式:

$radioElement = new Zend_Form_Element_Checkbox('formelement_0'); 
$radioElement->setLabel('Do you accept the <a href="#">Terms &amp; Conditions</a>?'); 
$radioElement->getDecorator('Label')->setOption('escape', false);