我有这段代码`
的在 <div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input type="text" placeholder="Username">
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-lock"></i></span>
<input type="password" placeholder="Password">
<a href="index.html"><span class="add-on" id="login"><i class="icon-arrow-right"></i></span></a>
</div>
我想在zend框架上写文件.phtml我使用MVC
能帮到我吗?我怎么能在zend框架上的.phtml文件上写一下
所以我使用这个<?php echo $this->element->loginAd->renderViewHelper(); ?>
,我不知道我是怎么做的<span class="add-on">
<i class="icon-user"></i>
</span>
在Syntxe中与zend视图相同
我想做同样的主题html / css
当我写这段代码时
`<form class="form-signin" name="login-form" id="login-form" method="<?php echo $this->escape($this->element->getMethod()); ?>" action="<?php echo $this->escape($this->element->getAction()); ?>">
<h2 class="form-signin-headin
g"><strong>Administration</strong></h2>
<div class="input-prepend">
<span class="add-on">
<i class="icon-user"></i>
</span>
<?php echo $this->element->loginAd->renderViewHelper(); ?>
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-lock"></i></span>
<?php echo $this->element->password->renderViewHelper(); ?>
<a href="index.html"><span class="add-on" id="login"><i class="icon-arrow-right"></i></span></a>
</div>
<?php echo $this->element->submit->renderViewHelper(); ?>
<p class="input-height">
<input type="checkbox" name="keep-logged" id="keep-logged" value="1" class="mini-switch" checked="checked">
<label for="keep-logged" class="inline"><?=$this->translate('Stay connected');?></label>
</p>
</form>`
感谢您的大力帮助
答案 0 :(得分:0)
您需要按照以下步骤操作 1.创建表单
namespace Application\Form;
use Zend\Form\Form;
use Zend\Db\Adapter\AdapterInterface;
use Zend\Db\Adapter\Adapter;
class UserForm extends Form
{
public function __construct()
{
parent::__construct('usser');
$this->setAttribute('method', 'post');
$this->addElement(
'text', 'username', array(
'label' => 'Username:',
'required' => true,
'filters' => array('StringTrim'),
));
$this->addElement('password', 'password', array(
'label' => 'Password:',
'required' => true,
));
$this->addElement('submit', 'submit', array(
'ignore' => true,
'label' => 'Login',
));
}
}
2在控制器或工厂中实例化那种最适合的形式 你
public function indexAction(){
$form = new UserForm($dbAdapter);
return array('form'=>$form);
}
- 在您的视图脚本index.phtml
中 醇>
<?php
$title = 'New Admin User ';
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title); ?></h1>
<?php
$form = $this->form;
$form->setAttribute('action', $this->url('user', array('action' => 'index')));
$form->prepare();
echo $this->form()->openTag($form);
foreach ($form as $element) { ?>
<?php
echo $this->formRow($element); ?>
<?php }?>
<?php
echo $this->form()->closeTag();
答案 1 :(得分:0)
你可以使用完全相同的html代码,只需用
替换输入<?php echo $this->formElement($form->get('name')) ?>
一个完整的例子是:
<?php echo $this->form()->openTag($form) ?>
<div class="form-group">
<?php echo $this->formLabel($form->get('name')); ?>
<?php echo $this->formElement($form->get('name')); ?>
</div>
<?php echo $this->form()->closeTag($form) ?>
对于占位符,请参阅amarjit sngh解决方案。