コード例 #1
0
 public function buildForm()
 {
     $this->clearElements();
     $hourForm = new Zend_Form_SubForm();
     foreach ($this->data as $record) {
         $elm = new Zend_Form_Element((string) $record['id']);
         $elm->setValue($record);
         $hourForm->addElement($elm);
     }
     $this->addSubForm($hourForm, $this->key_existing);
     // add template element
     $newForm = new Zend_Form_SubForm();
     $elm = new Zend_Form_Element('__unique__');
     $newForm->addElement($elm);
     // add elements based on $_POST, (this is crap but will do for now)
     if (isset($_POST['hour_new'])) {
         foreach ($_POST['hour_new'] as $idx => $values) {
             if ($idx != '__unique__') {
                 $elm = new Zend_Form_Element($idx);
                 $elm->setValue($values);
                 $newForm->addElement($elm);
             }
         }
     }
     $this->addSubForm($newForm, $this->key_new);
 }
コード例 #2
0
ファイル: DateRangePicker.php プロジェクト: anunay/stentors
 public function setValue($value)
 {
     $tmp = array();
     if (is_array($value)) {
         foreach ($value as $val) {
             if (empty($val['from']) && empty($val['to'])) {
                 continue;
             } else {
                 if (empty($val['to']) && (!empty($val['from']) && preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $val['from']))) {
                     $val['to'] = $val['from'];
                 }
             }
             array_push($tmp, $val);
         }
     }
     return parent::setValue($tmp);
 }
コード例 #3
0
ファイル: Frmproduct.php プロジェクト: sarankh80/opsstock
 public function frmSearch($data = null)
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $db = new Application_Model_DbTable_DbGlobal();
     $search_text = new Zend_Form_Element("txt_search");
     $search_text->setValue($request->getParam("txt_search"));
     $cat_id = new Zend_Form_Element_Select("cat_id");
     $cat_id->setAttribs(array('class' => 'select', 'style' => 'width:100%'));
     $category = $db->getAllProCategories();
     $option_category = array(0 => $this->tr->translate("CHOOSE_CATEGORY"));
     foreach ($category as $row_cat) {
         $option_category[$row_cat["cat_id"]] = $row_cat["cat_name_km"] . " - " . $row_cat["cat_name_en"];
     }
     $cat_id->setMultiOptions($option_category);
     $cat_id->setValue($request->getParam("cat_id"));
     $brand = new Zend_Form_Element_Select("brand");
     $brand->setAttribs(array('class' => 'select', 'style' => 'width:100%'));
     $row_brand = $db->getAllBrand();
     $option_brand = array(0 => $this->tr->translate("CHOOSE_BRAND"));
     foreach ($row_brand as $rs) {
         $option_brand[$rs["brand_id"]] = $rs["name_kh"] . " - " . $rs["name_en"];
     }
     $brand->setMultiOptions($option_brand);
     $brand->setValue($request->getParam("brand"));
     if ($data != null) {
     }
     return $this->addElements(array($search_text, $cat_id, $brand));
 }
コード例 #4
0
 /**
  * Carrega os modelos de impressao no elemento
  *
  * @param Zend_Form_Element $oElemento
  * @param string            $sValor
  * @return $this
  */
 public function setModelosImpressao(Zend_Form_Element $oElemento, $sValor = '')
 {
     $aValores = array('1' => 'Modelo 1', '2' => 'Modelo 2', '3' => 'Modelo 3', '4' => 'Modelo 4');
     $oElemento->addMultiOptions($aValores);
     $oElemento->setValue($sValor);
     return $this;
 }