簡體   English   中英

自定義提交按鈕

[英]Custom Submit button

如何創建提交按鈕,並在其上定義自定義標題以及自定義類樣式?

您可以使用Form幫助程序的submit()button()方法而不是end()方法。 例如:

echo $this->Form->submit(
    'Send', 
    array('class' => 'custom-class', 'title' => 'Custom Title')
);

別忘了關閉表格。 你可以通過調用沒有任何參數的end()方法來實現。

echo $this->Form->end();

還記得,你可以隨時做舊學校

我更喜歡使用$this->Form->end( ); 沒有參數並構建我自己的提交按鈕和標記。 這很簡單

<div class="buttons clearfix">
    <button type="submit" class="positive">
        <span class="icon-wrapper"><img src="path/to/tickmark.png" alt="" title="" /></span>
        Save Item
    </button>
</div>

我還會告訴你$this->Form->input('Model.field', 'options' => array( array('type' => 'button'))); - 特別是之前,之間,之后和類選項。 您可以使用幫助程序創建具有良好靈活性的<input type="button" />元素。

您可以通過此代碼創建costum

echo $this->Form->submit(
    'Submit', 
    array('div' => false,'class' => 'urclass', 'title' => 'Title')
);

這就夠了:

echo $this->Form->submit("Custom message");

同樣@Mike建議關閉表格

echo $this->Form->end();

我使用我的under app / webroot / img中的圖像創建了一個自定義按鈕,它使用內聯樣式指定大小並將位置更改為居中

$options=array('type'=>'Make secure payment', 'type'=>'image', 'style'=>'width:200px; height:80px; display:block; margin-left:auto; margin-right:auto;');
echo $this->Form->submit('/img/axiaepaysecurebuttongray_med.png', $options);
echo $this->Form->end();

對於CakePHP 2.x,您可以使用

$options = array(
    'label' => 'Update',
    'div' => array(
        'class' => 'glass-pill',
    )
);
echo $this->Form->end($options);

或者您可以將兩者結合使用:

echo $this->Form->end("Custom Message");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM