我正在修改CakePHP中的登录表单,并希望在“登录”按钮后添加“注册按钮”。但是CakePHP在这两个元素之间创建了换行符:
我的login.ctp文件:
<?php
/**
* Copyright 2010 - 2011, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2011, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<div class="row-fluid">
<div class="span4"></div>
<div class="span4">
<fieldset>
<?php
echo $this->Form->create($model, array(
'plugin' => 'users', 'controller' => 'users',
'language' => $this->Session->read('Config.language'),
'id' => 'LoginForm', 'class' => 'well'));
?>
<div class="row-fluid">
<?php
if ($_SERVER['HTTP_HOST'] == Configure::read('webakis.touchscreen_host')) {
echo $this->Form->input('name', array(
'label' => __('Name'), 'class' => 'span12'));
echo $this->Form->input('surname', array(
'label' => __('Surname'), 'class' => 'span12'));
} else {
echo $this->Form->input('email', array(
'label' => __('Email or name surname'), 'type' => 'text', 'class' => 'span12'));
}
echo $this->Form->input('password', array(
'label' => __('Password'), 'class' => 'span12'));
// echo '<p>' . $this->Form->checkbox('remember_me') . __( 'Remember Me') . '</p>';
//echo '<p>' . $this->Html->link(__( 'I forgot my password'), array('action' => 'reset_password')) . '</p>';
echo $this->Form->hidden('User.return_to', array(
'value' => $return_to));
// echo $this->Form->end(__( 'Sing in') );
?>
<div class="row-fluid">
<?php
echo $this->Form->submit(__('Sign in'), array('class' => 'btn span6'));
echo $this->Html->link(__('Create an Account'), array('plugin' => 'users', 'controller' => 'users', 'action' => 'add'), array('class' => 'btn span6'));
?>
</div>
<p><?php
if ($_SERVER['HTTP_HOST'] !== Configure::read('webakis.touchscreen_host')) {
echo $this->Html->link(__('Forgot your password?'), array('action' => 'reset_password'));
}
?>
</p>
<div class="btn btn-facebook"><i class="fa fa-facebook"></i>
<?php echo $this->Html->link('Connect with Facebook', $fb_login_url);?>
</div></br></br>
</div><?php echo $this->Form->end(); ?>
</form>
</fieldset>
</div>
<div class="span4"></div>
</div>
我试过使用Bootstrap&#34; row-fluid&#34;将它们放在一行中的类,但它不起作用。
答案 0 :(得分:4)
它不是<br>
中的换行符,而是按钮被包含在块元素中(默认情况下为div
)。
要么禁用它
echo $this->Form->submit(__('Sign in'), array(
'class' => 'btn span6',
'div' => false
));
或使用after
选项将其他按钮/链接注入包装元素:
$link = $this->Html->link(__('Create an Account'), array(
'plugin' => 'users',
'controller' => 'users',
'action' => 'add'
),
array('class' => 'btn span6'));
echo $this->Form->submit(__('Sign in'), array(
'class' => 'btn span6',
'after' => $link
));
另请参阅 http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options