Commit | Line | Data |
---|---|---|
2bf0718d J |
1 | <?php |
2 | ||
3 | require_once 'CRM/Core/Form.php'; | |
4 | require_once 'wci-helper-functions.php'; | |
5 | ||
6 | /** | |
7 | * Form controller class | |
8 | * | |
9 | * @see http://wiki.civicrm.org/confluence/display/CRMDOC43/QuickForm+Reference | |
10 | */ | |
11 | class CRM_Wci_Form_ProgressBar extends CRM_Core_Form { | |
12 | ||
13 | function preProcess() { | |
14 | CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.wci', 'addmore.js'); | |
15 | parent::preProcess(); | |
16 | } | |
17 | function buildQuickForm() { | |
18 | $this->add( | |
19 | 'text', // field type | |
20 | 'progressbar_name', // field name | |
21 | 'Name', // field label | |
22 | true // is required | |
23 | ); | |
24 | $this->add( | |
25 | 'text', // field type | |
26 | 'starting_amount', // field name | |
27 | 'Starting amount', // field label | |
28 | true // is required | |
29 | ); | |
30 | $this->add( | |
31 | 'text', // field type | |
32 | 'goal_amount', // field name | |
33 | 'Goal amount', // field label | |
34 | true // is required | |
35 | ); | |
36 | $this->add( | |
37 | 'select', // field type | |
38 | 'contribution_page_1', // field name | |
39 | 'Contribution page', // field label | |
40 | getContributionPageOptions(), // list of options | |
41 | true // is required | |
42 | ); | |
43 | $this->add( | |
44 | 'text', // field type | |
45 | 'percentage_1', // field name | |
46 | 'percentage', // field label | |
47 | true // is required | |
48 | ); | |
49 | //$this->getElement('percentage')->setAttribute("id", "percentage"); | |
50 | ||
51 | $this->addElement('link', 'addmore_link',' ', 'addmore', 'Add more'); | |
52 | // $this->addElement('link', 'remove_link',' ', 'remove', 'Remove'); | |
53 | ||
54 | $this->addElement('hidden', 'contrib_count', '1'); | |
55 | //$this->getElement('contrib_count')->setAttribute("id", "count"); | |
56 | ||
57 | $this->addButtons(array( | |
58 | array( | |
59 | 'type' => 'text', | |
60 | 'name' => ts('Add More'), | |
61 | 'isDefault' => FALSE, | |
62 | ), | |
63 | array( | |
64 | 'type' => 'submit', | |
65 | 'name' => ts('Save'), | |
66 | 'isDefault' => TRUE, | |
67 | ), | |
68 | )); | |
69 | ||
70 | // export form elements | |
71 | $this->assign('elementNames', $this->getRenderableElementNames()); | |
72 | ||
73 | parent::buildQuickForm(); | |
74 | } | |
75 | ||
76 | function postProcess() { | |
77 | echo "post pro"; | |
78 | $values = $this->exportValues(); | |
79 | $options = $this->getColorOptions(); | |
80 | /* CRM_Core_Session::setStatus(ts('You picked color "%1"', array( | |
81 | 1 => $options[$values['favorite_color']] | |
82 | )));*/ | |
83 | parent::postProcess(); | |
84 | } | |
85 | ||
86 | /* | |
87 | function getColorOptions() { | |
88 | $options = array( | |
89 | '' => ts('- select -'), | |
90 | '#f00' => ts('Red'), | |
91 | '#0f0' => ts('Green'), | |
92 | '#00f' => ts('Blue'), | |
93 | '#f0f' => ts('Purple'), | |
94 | ); | |
95 | foreach (array('1','2','3','4','5','6','7','8','9','a','b','c','d','e') as $f) { | |
96 | $options["#{$f}{$f}{$f}"] = ts('Grey (%1)', array(1 => $f)); | |
97 | } | |
98 | return $options; | |
99 | }*/ | |
100 | ||
101 | /** | |
102 | * Get the fields/elements defined in this form. | |
103 | * | |
104 | * @return array (string) | |
105 | */ | |
106 | function getRenderableElementNames() { | |
107 | // The _elements list includes some items which should not be | |
108 | // auto-rendered in the loop -- such as "qfKey" and "buttons". These | |
109 | // items don't have labels. We'll identify renderable by filtering on | |
110 | // the 'label'. | |
111 | $elementNames = array(); | |
112 | foreach ($this->_elements as $element) { | |
113 | $label = $element->getLabel(); | |
114 | if (!empty($label)) { | |
115 | $elementNames[] = $element->getName(); | |
116 | } | |
117 | } | |
118 | return $elementNames; | |
119 | } | |
120 | } | |
121 | ||
122 | function wci__civicrm_buildForm( $formName, &$form ) | |
123 | { | |
124 | echo "hi<br>"; | |
125 | //CRM_Core_Resources::singleton()->addScriptFile('wci', 'addmore.js'); | |
126 | CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.wci', 'addmore.js'); | |
127 | } |