Zend_Form ::如何从zend表单中删除所有标签?$title->removeDecorator('Label');一个但是所有元素?
谢谢
此时我正在使用Zend Framework中的Form.它必须成为一个公司可以填写候选人详细信息的表格.
我对Zend很新,所以这就是我发布问题的原因.
这就是表单的样子(删除了一些字段以缩短代码)
<?php
class Application_Form_Validate_ContactMethodSelected extends Zend_Validate_Abstract {
const INVALID = 'invalid';
protected $_messageTemplates = array(
self::INVALID => 'Ten minste 1 vorm van contact invullen, telefoon, mobiel of e-mail'
);
public function isValid($value, $context = array())
{
// You need to use your element names, consider making these dynamic
$checkFields = array('telefoon','mobiel','mail');
// Check if all are empty
foreach ( $checkFields as $field ) {
if (isset($context[$field]) && !empty($context[$field])) {
if (!empty($value)) {
// This is the element …Run Code Online (Sandbox Code Playgroud) 我努力了,但是我无法使装饰器像我的表格那样格式化:
<form>
<div class="form_wrapper">
<div class="form_label">
<!-- {{label}} -->
</div>
<div class="form_element">
<!-- {{element}} -->
</div>
</div> <!-- end .form_wrapper -->
<div class="form_wrapper">
<div class="form_label">
<!-- {{label}} -->
</div>
<div class="form_element">
<!-- {{element}} -->
</div>
</div> <!-- end .form_wrapper -->
</form>
Run Code Online (Sandbox Code Playgroud)
当我尝试设置课程是form_label为了我decorator:
array('Label', array('tag' => 'div', 'class' => 'form_label'))
Run Code Online (Sandbox Code Playgroud)
<div>
<label class="form_label">Title</label>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要将标签form_label内的类移动到父元素:标签吗?labeldiv
我怎样才能做到这一点?
我正在使用zend框架,并尝试使用zend表单,MVC和OOP输出一个简单的登录表单.
我的代码如下:Controller IndexController.php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->view->loginForm = $this->getLoginForm();
}
public function getLoginForm()
{
$form = new Application_Form_Login;
return $form;
}
}
Run Code Online (Sandbox Code Playgroud)
这是以下形式:Login.php
class Application_Form_Login extends Zend_Form
{
public function init()
{
$form = new Zend_Form;
$username = new Zend_Form_Element_Text('username');
$username
->setLabel('Username')
->setRequired(true)
;
$password = new Zend_Form_Element_Password('password');
$password
->setLabel('Password')
->setRequired(true)
;
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Login');
$form->addElements(array($username, $password, $submit));
}
}
Run Code Online (Sandbox Code Playgroud)
并且视图:index.phtml …
在ZF1表单的元素有一个setDescription是被输出作为方法<p>description here</p>鉴于.... ZF2显得那么我的问题是我怎样才能添加说明,形成元素没有这个方法?
这是我的看法:
<div>
<?
$form = $this->form;
$form->prepare();
echo $this->form()->openTag($form);
foreach ($form->getElements() as $el) {
?>
<div class="form_element">
<?=$this->formRow($el);?>
</div>
<?
}
echo $this->partial('system/form/buttons_form_part.phtml', array('form' => $form));
echo $this->form()->closeTag();
?>
</div>
Run Code Online (Sandbox Code Playgroud) 这是我的表格
<?php
namespace Home\Form;
use Zend\Form\Form;
class CheckPriceForm extends Form
{
public function __construct($name = null)
{
parent::__construct();
$this->add(array(
'name' => 'distance',
'type' => 'Zend\Form\Element\Number',
'options' => array(
'label' => 'Distance',
),
));
$this->add(array(
'name' => 'weight',
'type' => 'Zend\Form\Element\Number',
'options' => array(
'label' => 'Weight',
),
));
$this->add(array(
'name' => 'submit',
'type' => 'Submit',
'attributes' => array(
'value' => 'Check Price',
),
));
}
}
Run Code Online (Sandbox Code Playgroud)
给出以下错误
/home/dinuka/workspace/free_courier/vendor/ZF2/library/Zend/I18n/Validator/Float.php:49
Zend\I18n\Validator component requires the intl PHP extension
Run Code Online (Sandbox Code Playgroud)
当我替换电子邮件号码时,它正在工作.请帮我.
我有一个Zf2表单日期元素,我用这种方式,
$this->add(array(
'type' => 'Zend\Form\Element\Date',
'name' => 'releasedate',
'options' => array(
'label' => 'Release Date'
),
'attributes' => array(
'min' => '2012-01-01',
'max' => '2020-01-01',
'step' => '1',
)
));
Run Code Online (Sandbox Code Playgroud)
所以在chrome中我得到一个日期选择器但不是在safari或firefox中?我需要为此做任何新配置吗?
我的应用程序中有一个登录页面,但我想知道如何将用户的密码转换为点,以便当用户输入他或她的凭据时,她可以看到她的用户名,但密码是一个溺爱的公式.似乎无法在网上找到任何zend相关链接的例子也将受到赞赏.请记住,我正在使用zend形式.