actions['reoder_form'] = 'doReoderForm'; $this->actions['reoder_save'] = 'doReoderSave'; $this->actions['chng_showing_in_list'] = 'doChngShowingInList'; $this->DB_Grid($Page, $DBObj); } function _getNewForm() { $form = parent::_getNewForm(); $form->setDefaults(array('show_in_list' => 'y')); return $form; } function fieldValid($fields) { $errorMsgs = array(); $isValidValid = true; switch ($fields['type']) { case 'header': if (count($fields['valid'])){ $isValidValid = false; } break; case 'select': case 'checkboxes': case 'radioboxes': if (!isset($fields['value'])){ $errorMsgs['value'] = 'The valid options are required for this field type'; } case 'file': case 'checkbox': if (in_array('email', (array)$fields['valid']) ){ $isValidValid = false; } break; default: break; } if (!$isValidValid){ $errorMsgs['valid'] = 'This field type cannot be validated in this way'; } if (count($errorMsgs)){ return $errorMsgs; }else { return true; } } function _bindFormFields($form) { $form = parent::_bindFormFields($form); $form->addFormRule(array(&$this, 'fieldValid') ); $form->removeElement('sorter'); $form->removeElement('type'); // $form->addElement('header', 'label', 'Label'); require_once 'class/DB/Lang/DLang.php'; $DLang = new DLang(); $langList = $DLang->getList(); if (count($langList) > 1){ $form->addElement('header', 'title_header', 'Label'); } foreach ($langList as $lang){ if (count($langList) == 1){ $title_error = 'Label is required'; $title = 'Label'; }else{ $title_error = $lang['title'] . ' label is required'; $title = $lang['title']; } $name = "label[{$lang['name']}]"; $form->addElement('text', $name, $title, array('value' => $this->DBObj->getData($name)) ); $form->addRule($name, $title_error, 'required'); } $type = Form::createElement('select', 'type', 'Type', $this->DBObj->getTypes(), array('onChange' => 'showNode(this.value);') ); $type->setValue($this->DBObj->getData('type')); $form->addElement($type); $valid = Form::createElement('advmultiselect', 'valid', 'Validation', $this->DBObj->getValidators(), array('size' => 7) ); $template = ' {javascript} {label_2}  {label_3} {unselected} {add}
{remove}

{moveup}
{movedown} {selected} '; $valid->setElementTemplate($template); // $valid->setValue(array('one_of_set', 'email')); if (is_array($this->DBObj->getData('valid'))){ $valid->setValue((array)$this->DBObj->getData('valid')); } $form->addElement($valid); $form->removeElement('id_fm'); $form->addElement('hidden', 'id_fm', $this->DBObj->id_fm); $languageList = $DLang->getList(); if(count($languageList) > 1) { $arrTitle = $languageList; } else { $arrTitle = array(array('name'=>$DLang->getDefault(), 'title' => 'Values')); } $form->addElement('grid', 'value', 'Valid Options', $arrTitle, $this->DBObj->getData('value')); $form->removeElement('show_in_list'); $field_type = 'text'; if ($this->DBObj->getData('type')) { $field_type = $this->DBObj->getData('type'); } $show_in_list =& Form::createElement('advcheckbox', 'show_in_list', 'Show in list of submissions', '', null, array('n', 'y')); $show_in_list->setValue($this->DBObj->getData('show_in_list') ); $form->addElement($show_in_list); return $form; } function addLink() { $addLink = array( 'tpl' => 'center_link.tpl', 'link_list' => array( array('link' => "javascript:window.opener.addform(".$this->DBObj->id_fm.",'".$this->DBObj->getformName()."');window.close();", 'title' => '<< Back to Event'), array('link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=reoder_form&id_fm='.$this->DBObj->id_fm, 'title' => 'Reorder '.$this->DBObj->itemName.'s', ), array('link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=new&id_fm='.$this->DBObj->id_fm, 'title' => 'Add new '.$this->DBObj->itemName,), ), ); $this->Doc->addContent($addLink); } function _doListBind(&$DB_List) { $DB_List->def_order_by = 'sorter'; $DB_List->urlVarNames[] = 'id_fm'; $DB_List->insertColLast('label', array('title' => 'Label', 'order_by' => 'label', 'width' => '150', 'tpl' => DB_LIST_CELL_TEXT, 'default_text' => "empty label", 'params' => array('label'), )); $DB_List->insertColLast('type', array('title' => 'Type' , 'order_by' => $this->DBObj->tableName.'.type', 'width' => '150', 'tpl' => DB_LIST_CELL_TEXT, 'default_text' => "empty type", 'params' => array('type'), )); $DB_List->insertColLast('show_in_list', array('title' => 'Show in list', 'order_by' => 'show_in_list', 'width' => '150', 'tpl' => $this->DBObj->id_fm<4?DB_LIST_CELL_LINK:'Event/List/cells/link.tpl', 'default_text' => "empty type", 'url' => CURR_PAGE.'?action=chng_showing_in_list&id=', 'params' => array('id', 'show_in_list_title', 'id_fm'), )); $DB_List->insertColLast('options', array('title' => 'Options', 'width' => '150', 'tpl' => $this->DBObj->id_fm<4?DB_LIST_CELL_EDIT_DEL:'Event/List/cells/edit_del.tpl', 'edit_link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=edit&id=', 'del_link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=del&id=', 'params' => array('id', 'id_fm'), )); $DB_List->bind(); return true; } function _getReorderFrom() { $form = $this->_getBaseForm(); $list = array(); $list4Grid = $this->DBObj->getList4Grid(array('order_by' => 'sorter')); foreach ($list4Grid['list'] as $val) { $list[$val['id']] = $val['label']; } $orderList = Form::createElement('select_edit', 'order_list', false, $list); $orderList->delAction('add'); $orderList->delAction('del'); $orderList->delAction('edit'); $form->addElement($orderList) ; $form->addElement('hidden', 'id_fm', $this->DBObj->id_fm); return $form; } function doReoderForm() { $form = $this->_getReorderFrom(); $this->setFormTitle($form, 'Reorder '.$this->DBObj->itemName.'s'); $form->addElement('hidden', 'action', 'reoder_save') ; $form->exec(); } function doReoderSave() { $form = $this->_getReorderFrom(); $this->DBObj->reorder( $form->getElementValue('order_list') ); $this->doBack(); } function doChngShowingInList() { $this->DBObj->chngShowingInList(); $this->doBack(); } } ?>