- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我目前正在 ZF2 中重建骨架应用程序在“Zend Framework 2 文档,版本 2.3.3”中,有一个用于添加/编辑相册的表单。
在文档中,表单如下所示:
我一步一步地按照文档操作,但我的看起来像这样:
AlbumForm.php:
<?php
namespace Album\Form;
use Zend\Form\Form;
class AlbumForm extends Form
{
public function __construct($name = null)
{
parent::__construct('album');
$this->add(array(
'name' => 'id',
'type' => 'Hidden',
));
$this->add(array(
'name' => 'title',
'options' => array(
'label' => 'Title',
),
'attributes' => array(
'type' => 'text',
)
));
$this->add(array(
'name' => 'artist',
'options' => array(
'label' => 'Artist',
),
'attributes' => array(
'type' => 'text',
)
));
$this->add(array(
'name' => 'submit',
'attributes' => array(
'type' => 'submit',
'value' => 'Go',
'id' => 'submitbutton',
),
));
}
}
添加.phtml
<?php
$title = 'Add new album';
$this->headTitle($title);
?>
<h1><?= $this->escapeHtml($title); ?></h1>
<?php
$form->setAttribute('action', $this->url('album', array('action' => 'add')));
$form->prepare();
echo $this->form()->openTag($form);
echo $this->formHidden($form->get('id'));
echo $this->formRow($form->get('title'));
echo $this->formRow($form->get('artist'));
echo $this->formSubmit($form->get('submit'));
echo $this->form()->closeTag();
HTML 输出:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Add new album - ZF2 Tutorial</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Le styles -->
<link href="/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/css/bootstrap-theme.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/css/style.css" media="screen" rel="stylesheet" type="text/css">
<link href="/img/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
<!-- Scripts -->
<!--[if lt IE 9]><script type="text/javascript" src="/js/html5shiv.js"></script><![endif]-->
<!--[if lt IE 9]><script type="text/javascript" src="/js/respond.min.js"></script><![endif]-->
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><img src="/img/zf2-logo.png" alt="Zend Framework 2"/> Tutorial</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">Home</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<h1>Add new album</h1>
<form action="/album/add" method="POST" name="album" id="album"><input type="hidden" name="id" value=""><label><span>Title</span><input name="title" type="text" value=""></label><label><span>Artist</span><input name="artist" type="text" value=""></label><input name="submit" type="submit" id="submitbutton" value="Add"></form> <hr>
<footer>
<!--<p>© 2005 - 2014 by Zend Technologies Ltd. All rights reserved.</p>-->
</footer>
</div> <!-- /container -->
</body>
</html>
我希望有人知道我的错误是什么......
最佳答案
如果您使用 bootstrap3,则需要为输入字段添加适当的类所以你需要像这样改变你的 albumform.php:
<?php
namespace Album\Form;
use Zend\Form\Form;
class AlbumForm extends Form
{
public function __construct($name = null)
{
parent::__construct('album');
$this->add(array(
'name' => 'id',
'type' => 'Hidden',
));
$this->add(array(
'name' => 'title',
'options' => array(
'label' => 'Title',
),
'attributes' => array(
'type' => 'text',
'class' => 'form-control',//changed line
)
));
$this->add(array(
'name' => 'artist',
'options' => array(
'label' => 'Artist',
),
'attributes' => array(
'type' => 'text',
'class' => 'form-control',//add form-control class
)
));
$this->add(array(
'name' => 'submit',
'attributes' => array(
'type' => 'submit',
'value' => 'Go',
'id' => 'submitbutton',
'class' => 'btn btn-default'//add btn class
),
));
}
}
添加.phtml:
<?php
$title = 'Add new album';
$this->headTitle($title);
?>
<h1><?= $this->escapeHtml($title); ?></h1>
<?php
$form->setAttribute('action', $this->url('album', array('action' => 'add')));
$form->prepare();
echo $this->form()->openTag($form);
echo $this->formHidden($form->get('id'));
echo $this->formRow($form->get('title'));
echo '<br>';//separate line
echo $this->formRow($form->get('artist'));
echo '<br>';//separate line
echo $this->formSubmit($form->get('submit'));
echo $this->form()->closeTag();
谢谢你..
关于php - Zendframework 2 骨架应用程序 Albumform 样式丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26159554/
我正在尝试轻松记录所有应用程序错误。 ZendFramework 是否有可以执行此操作的插件,或者它可以在本地执行此操作? 最佳答案 输入你的配置: phpSettings.log_errors =
我想让这个问题成为那些对 ZendFramework 感兴趣的人的指南与其他库/框架的集成。在 StackOverflow 上搜索并没有给出关于该主题的广泛 View 。 问题是:您在当前基于 ZF
我的问题很简单: How do I add an API and/or 3rd party library to my ZendFramework application in a way which
我已经在 ubuntu 上安装了 zend 框架,并且安装正确。但现在我想更改 php.ini include_path 但我不知道我的 zend 框架库在我的 ubuntu 系统中的位置,我怎么知道
我使用的是 ZendFramework 2 和 TableGateway,它们适用于普通的选择语句。但我似乎无法找到如何使用 ZendFramework 2 select 获得列的最大值。我的选择应该
在./config/application.config.php return array( 'modules' => array( 'Application',
我有一个使用 ZendFramework 的非常大的 Web 应用程序。某处的SQL语句似乎有语法错误(很多东西是自动生成的),但记录的错误非常无用(项目信息已删除) Uncaught excepti
我一直在关注文件上传的 ZendFramework 文档: http://framework.zend.com/manual/2.1/en/modules/zend.form.file-upload.
我已经在我的网络服务器上安装了 ZendSkelletonApp,它使用 php-fpm(5.5+,因此启用了 opcache)和 apache 运行。 但是,对于开箱即用的示例应用程序,响应时间是
我正在尝试通过行的主键访问 fetchAll 调用(返回 Zend_Db_Table_Rowset_Abstract)的行。 我想知道除了遍历并找到所需的行之外,最简单的方法是什么。 最佳答案 如果我
我在我的本地主机上使用 composer 安装了 zend 框架。我使用 xampp 的内置 php 服务器来部署我的 zendframework 应用程序。安装后有错误日志“compact(): U
我是 Zend Framework 2 的新手,想知道是否有一种全局方式来设置日期默认时区。 我知道我应该能够添加代码: date_default_timezone_set("UTC"); 但是我已经
在 Zendframework-1 中,我们通常将自定义代码保存在 library 文件夹下(与 application 文件夹平行)几乎使用与 zend 框架(供应商)库相同的文件夹结构来创建插件或
我正在使用 ZendFramework 和 PHP,我想设置和获取一个变量作为全局变量。 IE。我将其设置在 Zend Controller 的类中,并访问该类中的任何操作。 例如: EMAIL 获取
我有一个包含字段 id、标识符、名称的 pgsql 表。 id serial NOT NULL, identifier character varying(16), name charac
我在 ZendFramework 中的 MYSQL 查询遇到一些问题,我想获得过去 24 小时内的平均调用持续时间并进行如下查询: SELECT AVG(duration) FROM table1 w
您好,我想将 schemadb 与 ZendFramework 集成,以便在更改 Zend 模型时执行自动数据库模式调整 https://sourceforge.net/p/schemadb/wiki
如果我使用方法,例如在 ZF 中插入、更新我会安全吗(mysql 注入(inject))? 例如部分代码: $data = array( 'au
我想在对象数组上应用 Zend_Filter_StripTags $my_result = $obj->listdata(calling select query from model) 返回的数组是
我需要将一些表单元素放入表格中。我有一个问题,我的 HtmlTag 装饰器只包装了我的输入字段而不是标签,即使我更改了添加装饰器的顺序也是如此。标签突出标签。有什么建议吗?
我是一名优秀的程序员,十分优秀!