implementation of the extended class. Here's my complete form code.
Also, I'm still trying to improve my implementation of the Zend_Form
and related classes, so if you see any needless redundancy or areas of
improvement, please let me know!
/*********************** Form code ***********************/
class Form_ViewTrailersDojo extends Zend_Dojo_Form
{
protected $_fowlerTrailers = null;
protected $_puebloTrailers = null;
protected $_trailerTypes = null;
/**
* @constructor
*/
public function __construct(
Zend_Db_Table_Rowset $fowlerTrailers,
Zend_Db_Table_Rowset $puebloTrailers,
Zend_Db_Table_Rowset $trailerTypes,
$options = null )
{
$this->_fowlerTrailers = $fowlerTrailers;
$this->_puebloTrailers = $puebloTrailers;
$this->_trailerTypes = $trailerTypes;
parent::__construct($options);
}
/**
* 'fowlerTrailerId' text element
*
* Format the types array using the
* database result passed to the constructor
*
*/
public function init()
{
/**
* configure form output and fieldset
*/
$this->setDecorators( array(
'FormElements',
array('DijitForm', array('id' => 'myTrailerSelectForm', 'method' => 'post')),
array('BorderContainer', array('id' => 'myBorderContainer', 'style'
=> 'width: 100%; height: 100%;', 'dijitParams' => array('gutters' =>
'true') ) ),
));
//$this->setElementDecorators(array('DijitElement', 'Label'));
// fowlerTrailers element
$trailers = array('' => '');
foreach( $this->_fowlerTrailers as $row ) {
( $row->is_new ) ? $isNew = 'N' : $isNew = 'U';
$trailers[$row->trailer_id] = "$isNew (" . substr( $row->vin, -4, 4
) . ') ' .$row->year . ' ' . $row->mfr . ' ' .
$row->width . 'X' . $row->length . ' ' . $row->type;
}
$this->addElement('FilteringSelect', 'fowlerTrailerId', array(
'label' => 'Fowler (' . count( $this->_fowlerTrailers ) . '):',
'multiOptions' => $trailers,
'style' => 'width: 450px;'));
/**
* 'puebloTrailerId' text element
*
* First, format the types array using the
* database result passed to the constructor
*
* @param array $puebloTrailers
*
*/
$trailers = array('' => '');
foreach( $this->_puebloTrailers as $row ) {
( true == $row->is_new ) ? $isNew = 'N' : $isNew = 'U';
$trailers[$row->trailer_id] = "$isNew (" . substr( $row->vin, -4, 4
) . ') ' .$row->year . ' ' . $row->mfr . ' ' .
$row->width . 'X' . $row->length . ' ' . $row->type;
}
$this->addElement('FilteringSelect', 'puebloTrailerId', array(
'label' => 'Pueblo (' . count( $this->_puebloTrailers ) . '):',
'multiOptions' => $trailers,
'style' => 'width: 450px;'));
/**
* 'type' text element
*
* First, format the types array using the
* database result passed to the constructor
*
* @param array $trailerTypes
*
*/
$types = array( '' => '' );
foreach( $this->_trailerTypes as $row ) {
$types[$row->type] = $row->type;
}
$this->addElement('FilteringSelect', 'type', array(
'label' => 'Type:',
'multiOptions' => $types));
/**
* 'vin' text element
*/
$this->addElement('TextBox', 'vin', array(
'label' => 'Last 4 of VIN:',
'attribs' => array('maxlength' => 4, 'style' => 'width: 60px;') ) );
/**
* 'trailer_id' text element
*/
$this->addElement('TextBox', 'trailer_id', array(
'label' => 'Stock #:',
'attribs' => array('maxlength' => 5, 'style' => 'width: 60px;') ) );
/**
* 'submit' submit button element
*/
$this->addElement('SubmitButton', 'submitButton', array(
'label' => 'View'));
$this->submitButton->addDecorator('HtmlTag', array('tag' => 'div',
'class' => 'buttons', 'placement' => 'prepend', 'openOnly' => true))
->removeDecorator('DtDdWrapper');
/**
* 'back' submit button element
*/
$this->addElement('Button', 'resetButton', array(
'label' => 'Reset',
'type' => 'button',
'onclick' =>
"window.location.href='http://www.trtrailer.org/trailers/index/requestId/"
. mt_rand(50000, 70000) . "/'"));
$this->resetButton->addDecorator('HtmlTag', array('tag' => 'div',
'placement' => 'append', 'closeOnly' => true))
->removeDecorator('DtDdWrapper');
$this->addDisplayGroup(array( 'fowlerTrailerId', 'puebloTrailerId',
'type', 'vin', 'trailer_id', 'submitButton', 'resetButton'),
'myElements');
$this->myElements->addDecorator('Fieldset', array('legend' =>
'Trailer Selector'));
}
}
--
Regards,
Nathan
没有评论:
发表评论