public function buildForm() { $id = $this->config->param['id']; $form = new Zkernel_Form(array('accept-charset' => 'utf-8', 'onsubmit' => 'return c.submit()', 'id' => 'c_form')); if ($this->config->field) { $d = array(); $d1 = $this->config->field->toArray(); foreach ($d1 as $k => $v) { $d[$k] = @$v['order']; unset($this->config->field->{$k}); } array_multisort($d, SORT_ASC, SORT_NUMERIC, $d1); $this->config->field->set($d1); $fields = $this->config->field; if ($this->config->zk_meta) { $fields['meta_title'] = array('title' => 'Title', 'description' => $this->config->control_lang_current['meta_title'], 'order' => 2000); $fields['meta_keywords'] = array('title' => 'Keywords', 'description' => $this->config->control_lang_current['meta_keywords'], 'order' => 2001); $fields['meta_description'] = array('title' => 'Description', 'description' => $this->config->control_lang_current['meta_description'], 'order' => 2002); /*$fields['meta_show_title'] = array( 'title' => $this->config->control_lang_current['meta_show_title_title'], 'description' => $this->config->control_lang_current['meta_show_title'], 'type' => 'select', 'param' => array( 'multiOptions' => array('1' => 'Да', '0' => 'Нет') ), 'order' => 2003 );*/ } foreach ($fields as $el) { if (!$el->active) { continue; } if (@(int) $this->config->post['sposted'] && !array_key_exists($el->name, $this->config->post->toArray())) { continue; } $p = new Zkernel_Config_Control($el->param, array('label' => $el->title, 'description' => $el->description, 'required' => $el->required ? true : false, 'validators' => $el->validators ? $el->validators : array())); if ($el->unique) { $select = $this->config->model->getAdapter()->select()->where('`id` != ?', $id); if (isset($el->unique->where)) { $select->where($el->unique->where); } $p->validators[] = array('validator' => 'Db_NoRecordExists', 'options' => array($this->config->model->info('name'), $el->name, implode(' ', $select->getPart(Zend_Db_Select::WHERE)))); } if ($el->type == 'textarea') { $p->rows = 10; } if ($el->type == 'editarea') { $p->rows = 15; } if ($el->type == 'uploadify') { if (!isset($p->button)) { $p->button = $this->config->control_lang_current['button']; } if (!isset($p->destination)) { $p->destination = PUBLIC_PATH . '/upload/' . $this->config->controller . '_' . $el->name; } /*if (!isset($p->fn)) { $where = $this->config->where ? $this->config->where->toArray() : array(); $where['`id` = ?'] = $id; if ($this->config->use_db) $p->fn = $this->config->model->fetchOne($el->name, $where); }*/ } if ($el->type == 'mce') { if (!isset($p->lang)) { $p->lang = $this->config->control_lang; } } if ($el->type == 'select') { $p->class = 'c_select'; } else { if ($el->type == 'textarea') { $p->class = 'ui-state-default ui-corner-all c_textarea'; } else { $p->class = 'ui-state-default ui-corner-all c_input'; } } $form->addElement($el->type, $el->name, $p->toArray()); } if ($this->config->zk_meta && !@(int) $this->config->post['sposted']) { $form->addDisplayGroup(array('meta_title', 'meta_keywords', 'meta_description', 'meta_show_title'), 'meta', array('legend' => $this->config->control_lang_current['more'], 'class' => 'c_collapse')); } } $form->addElement('submit', 'oac_ok', array('label' => $this->config->oac_ok_title, 'class' => 'c_button')); $oac_array = array('oac_ok'); if ($this->config->oac_cancel) { $oac_array[] = 'oac_cancel'; $form->addElement('submit', 'oac_cancel', array('label' => $this->config->control_lang_current['cancel'], 'onclick' => 'return c.go("' . $this->config->request_cancel->controller . '", "' . $this->config->request_cancel->action . '", ' . Zend_Json::encode(Zkernel_Common::url2array($this->config->request_cancel->param)) . ')', 'class' => 'c_button')); } if ($this->config->oac_apply) { $oac_array[] = 'oac_apply'; $form->addElement('submit', 'oac_apply', array('label' => $this->config->control_lang_current['submit'], 'onclick' => 'return c.submit(1)', 'class' => 'c_button')); } $form->addDisplayGroup($oac_array, 'oac'); return $form; }