Custom Submit button

旧巷老猫 提交于 2020-01-02 00:47:17

问题


How can I create submit button, and define custom title on it, together with custom class style?


回答1:


Also remember, you can always do it old school

I prefer to use $this->Form->end( ); without arguments and build my own submit buttons and markup. It's easy

<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>

I would also tell you to experiment with the $this->Form->input('Model.field', 'options' => array( array('type' => 'button'))); - particularly the before, between, after, and class options. You can use the helper to create <input type="button" /> elements with a good amount of flexibility.




回答2:


You could use either submit() or button() methods of the Form helper instead of the end() method. For example:

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

Don't forget to close the form. You can do it by calling the end() method without any arguments.

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



回答3:


you can create costum submit by this code

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



回答4:


This is enough:

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

Also as @Mike suggest close the form with

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



回答5:


Or you can combine both with:

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



回答6:


I created a custom button using an image in my under app/webroot/img that uses inline style for specifying size and changing the position to center

$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();



回答7:


For CakePHP 2.x, you can use

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


来源:https://stackoverflow.com/questions/3182110/custom-submit-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!