Hi.
I have this form:
class Automobili_Form_Search extends Zend_Form {
/**
* Constructor.
*
* @param mixed $options
*/
public function __construct($options = null) {
parent::__construct($options);
// Add brand
$brand = new Zend_Form_Element_Select(array(
'name' => 'brand',
'class' => 'select-car-brand'
));
$brand->helper = 'FormSelectBrand';
$brandModel = new Automobili_Model_Brand();
$brand->setMultiOptions($brandModel->fetchAllOptions());
$brand->setLabel('Marka:');
$this->addElement($brand);
// Add model
$model = new Zend_Form_Element_Select(array(
'name' => 'model'
));
$model->setMultiOptions(array(0 => 'Nebitno'));
$model->setLabel('Model:');
$this->addElement($model);
// Add location
$location = new Zend_Form_Element_Select(array(
'name' => 'location'
));
$locationModel = new Automobili_Model_Location();
$location->setMultiOptions($locationModel->fetchAllOptions());
$location->setLabel('Lokacija:');
$this->addElement($location);
// Slider decorators
$sliderDecorators = array(
array('HtmlTag', array('tag' => 'div', 'class' =>
'slider', 'placement'
=> 'append')),
'Label',
'ViewHelper',
);
// Year from
$yearFrom = new Zend_Form_Element_Select(array(
'name' => 'year_from',
'class' => 'hidden',
));
$year = new Automobili_Model_Car_Year();
$yearOptions = $year->fetchAllOptions('od ');
$yearFrom->setMultiOptions($yearOptions);
$yearFrom->setLabel('Godište:');
$yearFrom->setDecorators($sliderDecorators);
$this->addElement($yearFrom);
// Year to
$yearTo= new Zend_Form_Element_Select(array(
'name' => 'year_to',
'class' => 'hidden',
'value' => $year->getYear()
));
$yearOptions = $year->fetchAllOptions('do ');
$yearTo->setMultiOptions($yearOptions);
$yearTo->setDecorators($sliderDecorators);
$this->addElement($yearTo);
// Price from
$priceFrom = new Zend_Form_Element_Select(array(
'name' => 'price_from',
'class' => 'hidden'
));
$priceFrom->setMultiOptions(Automobili_Model_Car_Price::fetchAllOptions());
$priceFrom->setLabel('Cena:');
$priceFrom->setDecorators($sliderDecorators);
$this->addElement($priceFrom);
// Year to
$priceTo= new Zend_Form_Element_Select(array(
'name' => 'price_to',
'class' => 'hidden',
'value' => Automobili_Model_Car_Price::MAX_PRICE
));
$priceTo->setMultiOptions(Automobili_Model_Car_Price::fetchAllOptions());
$priceTo->setDecorators($sliderDecorators);
$this->addElement($priceTo);
// Add sort by
$sortBy = new Zend_Form_Element_Select(array(
'name' => 'sort_by'
));
$sortBy->setMultiOptions(array(
'Starosti oglasa',
'Ceni'
));
$sortBy->setLabel('Sortiraj po:');
$this->addElement($sortBy);
// Setup form element decorators
$this->setElementDecorators(
array('ViewHelper', 'Label'),
array('price_from', 'price_to', 'year_from', 'year_to'),
false
);
// Add button
$submit = new Zend_Form_Element_Button(array(
'name' => 'quick-search-submit',
'label' => ' Traži',
'escape' => false,
'class' => 'ui-corner-all ui-button ui-state-default'
));
$submit->setDecorators(array('ViewHelper'));
$this->addElement($submit);
// Setup form
$this->setDecorators(array('FormElements', 'Form'));
$this->addAttribs(array(
'id' => 'quick-search-form'
));
}
}
During the form initialiation, I'm performing 2 queries to get options for
selects:
0.00131 SELECT `brand`.* FROM `brand` ORDER BY `title` ASC
0.00082 SELECT `location`.* FROM `location` ORDER BY `title` ASC
which are pretty fast as you can see.
Form constructor (initialization) takes 3.11 and rendering takes 2.25
seconds. This numbers depends on server speed ofc, but still pretty slow.
Is this normal?
Regards,
Saša Stamenković.
--
View this message in context:
http://www.nabble.com/Zend-form-performances-tp25676415p25676415.html
Sent from the Zend Framework mailing list archive at Nabble.com.