···103103 return $opts_s;
104104 }
105105106106+ /* generate <option> tags for each identifier in php's timezone list */
107107+ protected function time_zone_options_for_select($selected) {
108108+ $str = "";
109109+110110+ foreach (\DateTimeZone::listIdentifiers() as $tz)
111111+ $str .= "<option value=\"" . $tz . "\""
112112+ . (strtolower($selected) === strtolower($tz) ?
113113+ " selected" : "") . ">" . h($tz) . "</option>";
114114+115115+ return $str;
116116+ }
117117+106118 /* for each attribute in a form_for() object that has errors, output a div
107119 * around it that should be styled to stand out */
108120 protected function wrap_field_with_errors($field, $field_html) {
+14
lib/helpers/form_helper.php
···213213 $options), $options)
214214 );
215215 }
216216+217217+ /* create a <select> of grouped time zones */
218218+ public function time_zone_select($field, $options = array()) {
219219+ if (!$this->form_object)
220220+ throw new HalfMoonException("no form object; you probably wanted "
221221+ . "time_zone_select_tag");
222222+223223+ $options = $this->set_field_id_and_name($field, $options);
224224+225225+ return $this->wrap_field_with_errors($field,
226226+ $this->time_zone_select_tag($field,
227227+ $this->value_for_field($field, $options), $options)
228228+ );
229229+ }
216230}
217231218232?>
+10
lib/helpers/form_tag_helper.php
···170170171171 return "<input" . $this->options_to_s($options) . " />";
172172 }
173173+174174+ /* create a <select> of grouped time zones */
175175+ public function time_zone_select_tag($field, $selected = null,
176176+ $options = array()) {
177177+ $options = FormTagHelper::set_field_id_and_name($field, $options);
178178+179179+ return "<select" . $this->options_to_s($options) . ">"
180180+ . $this->time_zone_options_for_select($selected)
181181+ . "</select>";
182182+ }
173183}
174184175185?>