开发者

CakePHP - Have the label and form in Form helper on different line

I'm using this code now

echo $form->input('username');

How do 开发者_高级运维I make sure the label shows up on a different line than the input field?

I managed to imitate what I'm trying to do, just want to make sure that I'm using it the right way.

echo $form->label('username', 'Username');

echo $form->input('username', array('label' => false));

Thanks,

Tee


The core of your request is putting a line-break between the <label> and <input> tags created by the FormHelper::input method. You can accomplish this in several ways. Probably the simplest option is the following:

echo $form->input('User.username', array('between'=>'<br />'));

Or you could also use a pure CSS solution, something like:

<style type="text/css">
    div.input label { display: block; }
</style>
<?php echo $form->input('User.username'); ?>

This second option would leave you with cleaner PHP in your views, at the cost of more potential layout/stylesheet headaches.


Try this out.

<p>Username</p>    
<?php echo $form->input('username', array('div' => false, 'label' => false)) ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜