static function buildQuickForm(&$form, $blockId, $blockEdit = FALSE) { $form->add('select', 'contribution_page_' . $blockId, 'Contribution page', getContributionPageOptions(), true); $form->add('select', 'financial_type_' . $blockId, 'Financial type', getFinancialTypes(), false); $form->add('text', 'contribution_start_date_' . $blockId, ts('Start Date'), true); $form->add('text', 'contribution_end_date_' . $blockId, ts('End Date')); $form->add('text', 'percentage_' . $blockId, 'Percentage', array('value' => '100'), true); }
function buildQuickForm() { // add form elements $this->add('text', 'title', ts('Title'), true, true)->setSize(45); $this->add('text', 'logo_image', ts('Logo image'))->setSize(45); $this->add('text', 'image', ts('Image'))->setSize(45); $this->add('select', 'button_link_to', ts('Contribution button'), getContributionPageOptions()); $this->add('text', 'button_title', ts('Contribution button title'))->setSize(45); $this->add('select', 'progress_bar', ts('Progress bar'), $this->getProgressBars()); $pbtype = array(); $pbtype[1] = "Percentage"; $pbtype[0] = "Amount"; $this->addRadio('show_pb_perc', ts('Progressbar caption type'), $pbtype, NULL, " "); $this->addWysiwyg('description', ts('Description'), ''); $this->add('select', 'email_signup_group_id', ts('Newsletter signup'), $this->getGroupOptions()); $this->add('select', 'size_variant', ts('Size variant'), $this->getSizeOptions()); $this->add('checkbox', 'hide_title', ts('Hide Title')); $this->add('checkbox', 'hide_border', ts('Hide border')); $this->add('checkbox', 'hide_pbcap', ts('Hide progress bar caption')); foreach ($this->_colorFields as $name => $val) { $this->addElement($val[1], $name, $val[0], $name, $val[2]); } $this->add('textarea', 'style_rules', ts('Additional Style Rules'), 'style=width:94%')->setRows(5); $this->add('checkbox', 'override', ts('Override default template')); $this->add('textarea', 'custom_template', ts('Custom template:<br><SMALL><font color="red">Please customize the smarty v2 template only if you know what you are doing</font></SMALL>'), 'style=width:94%')->setRows(10); $this->addElement('submit', 'preview', 'name="Save and Preview" id="preview"'); $this->addButtons(array(array('type' => 'submit', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'next', 'name' => ts('Save & Preview')))); // export form elements $this->assign('elementNames', $this->getRenderableElementNames()); if (isset($this->_id)) { $query = "SELECT * FROM civicrm_wci_widget WHERE id=%1"; $params = array(1 => array($this->_id, 'Integer')); $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget'); while ($dao->fetch()) { $wid_page[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $wid_page[$dao->id]); $this->setDefaults(array('title' => $wid_page[$dao->id]['title'])); $this->setDefaults(array('logo_image' => $wid_page[$dao->id]['logo_image'])); $this->setDefaults(array('image' => $wid_page[$dao->id]['image'])); $this->setDefaults(array('button_link_to' => $wid_page[$dao->id]['button_link_to'])); $this->setDefaults(array('button_title' => $wid_page[$dao->id]['button_title'])); $this->setDefaults(array('progress_bar' => $dao->progress_bar_id)); $description = $wid_page[$dao->id]['description']; $this->setDefaults(array('description' => $description)); $this->setDefaults(array('email_signup_group_id' => $wid_page[$dao->id]['email_signup_group_id'])); $this->setDefaults(array('size_variant' => $dao->size_variant)); $this->setDefaults(array('color_title' => $wid_page[$dao->id]['color_title'])); $this->setDefaults(array('color_title_bg' => $wid_page[$dao->id]['color_title_bg'])); $this->setDefaults(array('color_bar' => $wid_page[$dao->id]['color_progress_bar'])); $this->setDefaults(array('color_bar_bg' => $wid_page[$dao->id]['color_progress_bar_bg'])); $this->setDefaults(array('color_widget_bg' => $wid_page[$dao->id]['color_widget_bg'])); $this->setDefaults(array('color_description' => $wid_page[$dao->id]['color_description'])); $this->setDefaults(array('color_border' => $wid_page[$dao->id]['color_border'])); $this->setDefaults(array('color_button' => $wid_page[$dao->id]['color_button'])); $this->setDefaults(array('color_button_bg' => $wid_page[$dao->id]['color_button_bg'])); $this->setDefaults(array('style_rules' => $wid_page[$dao->id]['style_rules'])); $this->setDefaults(array('override' => $wid_page[$dao->id]['override'])); $this->setDefaults(array('hide_title' => $wid_page[$dao->id]['hide_title'])); $this->setDefaults(array('hide_border' => $wid_page[$dao->id]['hide_border'])); $this->setDefaults(array('hide_pbcap' => $wid_page[$dao->id]['hide_pbcap'])); $this->setDefaults(array('show_pb_perc' => $wid_page[$dao->id]['show_pb_perc'])); $this->setDefaults(array('color_btn_newsletter' => $wid_page[$dao->id]['color_btn_newsletter'])); $this->setDefaults(array('color_btn_newsletter_bg' => $wid_page[$dao->id]['color_btn_newsletter_bg'])); $this->setDefaults(array('newsletter_text' => $wid_page[$dao->id]['newsletter_text'])); $this->setDefaults(array('color_newsletter_text' => $wid_page[$dao->id]['color_newsletter_text'])); if (true == $wid_page[$dao->id]['override']) { $cust_templ = html_entity_decode($wid_page[$dao->id]['custom_template']); $this->setDefaults(array('custom_template' => $cust_templ)); } else { $output = file_get_contents('templates/CRM/Wci/Page/WCIWidget.tpl', FILE_USE_INCLUDE_PATH); $elem = $this->getElement('custom_template'); $elem->setValue($output); } } CRM_Utils_System::setTitle(ts('Edit Widget')); } else { CRM_Utils_System::setTitle(ts('Create Widget')); $output = file_get_contents('templates/CRM/Wci/Page/WCIWidget.tpl', FILE_USE_INCLUDE_PATH); $elem = $this->getElement('custom_template'); $elem->setValue($output); } parent::buildQuickForm(); }