English 中文(简体)
Zend-form set 数值,视像<投入价值=”
原标题:Zend-form setValue , view has empty value like <input value="" >

我使用Zend-Form建立了相当复杂的表格。 在一点一点,用下列方法确定隐藏投入的价值:

$oHidden = new Zend_Form_Element_Hidden( ratings .$k);        
$oHidden->setValue( ratings );Zend_Debug::dump($oHidden);
$this->addElements(array($oHidden));

这种方法在同样形式的其他地点运作良好,但这种方式和另一个类似“一”产出:

<input type="hidden" name="ratings1" value="" id="ratings1" />

我丢掉了含热量变量,其产出如下:

object(Zend_Form_Element_Hidden)#143 (29) {
... ["_value":protected] => string(7) "ratings" ["_view":protected] => NULL ["_isPartialRendering":protected] => bool(false) }

因此,它只为一小时设定了价值,但并没有使之达到。 让我知道,在什么地方开始研究这种行为的原因。

Thanks, Alek

问题回答

问题恰恰是isValid(>功能。 它从形式上清除了所有价值,然后又重新渗透到形式上的各个参数。 如果一小米不在,则表面上似乎就算得更重,即使早先已明确划定了几条线。

我的案件是一种选择性的“直接”隐蔽领域,其形式是标志。 本条准则(可读性简单化):

$form = new Form_Login();
$redirect = $this->_getParam( redirect , /user/login/welcome );
$form->addElement( Hidden , redirect ,array( value  => $redirect));

if ($this->_request->isPost() && $form->isValid($this->_getAllParams())) {
    // WTF! the "request" field has no value!!!
}

工作区正在确定行动区段:

$form = new Form_Login();
$redirect = $this->_getParam( redirect , /user/login/welcome );
$this->_setParam( redirect ,$redirect);
$form->addElement( Hidden , redirect ,array( value  => $redirect));

if ($this->_request->isPost() && $form->isValid($this->_getAllParams())) {
    // AHA! now it works!
}

我知道这个问题是半年老的,但说得好,比过去更晚:D。

$hidden = new Zend_Form_Element_Hidden(array( name  =>  ratings ,  value  =>  ratings ));

!!





相关问题
Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

Tagging with Zend Framework

I m trying to create the same solutions as below, but using a simple MySQL query (instead of the static version used below where the words/tags are implemented in the code). The name of the MySQL ...

dynamicaly adding textboxes to zend_form

I hope that this is a quick question to answer. I am developing a form using Zend_Form, I have a number of Zend_Dojo_Form_Element_Textboxs to add to this form dynamically. These are added from rows ...

热门标签