<?php
class Forms_LpaManageEmailForm extends Zend_Form
{
protected $_actionUrl;
protected $_entry_id;
protected $_flag;
public function __construct($actionUrl, $options=null, $entry_id, $flag)
{
$this->addPrefixPath('ZFBlog_Form_Decorator', 'ZFBlog/Form/Decorator/', 'decorator');
parent::__construct($options);
$this->setActionUrl($actionUrl);
$this->setEntryId($entry_id);
$this->setFlag($flag);
$this->init();
}
public function setActionUrl($actionUrl) {
$this->_actionUrl = $actionUrl;
return $this;
}
public function setEntryId($entry_id){
$this->_entry_id = $entry_id;
return $this;
}
public function getEntryId(){
return $this->_entry_id['entry_id'];
}
public function setFlag($flag) {
$this->_flag = $flag;
}
public function getFlag() {
return $this->_flag;
}
public function init()
{
$this->setAction($this->_actionUrl)
->setMethod('post')
->setAttribs(array('id' => 'descriptionform', 'onSubmit' => 'multipleSelectOnSubmit()'));
$this->clearDecorators();
...
$this->addElement('hidden', 'id', array(
'validators' => array(
'Digits'
),
'required' => true,
'value' => $this->_entry_id['entry_id'],
));
...
$this->addElement($submit);
...
}
private function _addMultiOptionsForMultiSelect()
{
...
}
public function render(Zend_View_Interface $view = null)
{
$this->_addMultiOptionsForMultiSelect();
return parent::render($view);
}
public function isValid($data)
{
$this->_addMultiOptionsForMultiSelect();
return parent::isValid($data);
}
}
<?php
class Default_Form_CartReport extends Forms_LpaManageEmailForm
{
protected $_orderId;
public function __construct($actionUrl, $options=null, $entry_id, $flag=null, $orderId)
{
$this->setOrderId($orderId);
parent::__construct($actionUrl, $options=null, $entry_id, $flag);
}
public function setOrderId($orderId){
$this->_orderId = $orderId;
return $this;
}
public function setValue($value)
{
$strippedValue = stripslashes($value);
return parent::setValue($strippedValue);
}
public function init(){
parent::init();
$this->id->setValue('100'); // experimental method. doesn't work... debugger shows
//["_value":protected] => string(3) "100" , but in HTML output it's empty
/* $this->addElement('hidden', 'id', array(
'validators' => array(
'Digits'
),
'required' => true,
'value' => '100',
));*/ creating the element with the same name doesn't make any sense
Zend_Debug::dump($this->getElements());
}
private function _addMultiOptionsForMultiSelect()
{
...
}
public function render(Zend_View_Interface $view = null)
{
$this->_addMultiOptionsForMultiSelect();
return Zend_Form::render($view);
}
public function isValid($data)
{
$this->_addMultiOptionsForMultiSelect();
return Zend_Form::isValid($data);
}
}