function selectFrom($taxonomy) { $terms = array(); $options = array(); $html = ' '; foreach ($taxonomy as $term) { array_push($terms, $term); array_push($options, getOptionsfrom($term)); } $html .= renderSelect('filter', $terms); // $html .= '<select id="placeholder"></select>'; foreach ($options as $key => $value) { $html .= renderSelect($terms[$key], $value); } return $html; }
$connects = array('Frankfurt' => array('Alicante', 'Mallorca', 'Monastir', 'Hamburg', 'Amsterdam'), 'Munich' => array('Vienna', 'Warsaw', 'Prague', 'Rome', 'London City'), 'London Stansted' => array('Helsinki', 'Gothenburg', 'Copenhagen', 'Riga'), 'London City' => array('Munich', 'Hamburg', 'Hannover', 'Brussels'), 'Glasgow' => array('London Stansted', 'Dublin', 'Bergen'), 'Cork' => array('Dublin', 'Belfast', 'Birmingham', 'Liverpool')); foreach (array_keys($_POST) as $d) { $p[$d] = strip_tags($_POST[$d]); } if (!isset($p['airport'])) { echo '<h2>Please choose your journey start - Step 1 of 3</h2><p>'; echo renderSelect('airport', $airports, 'Start'); echo '</p>'; } if (isset($p['airport']) && !isset($p['destination'])) { echo '<h2>Please choose your journey end - Step 2 of 3</h2><p>'; echo 'Start: <strong>' . $p['airport'] . '</strong>'; echo '<input type="hidden" id="airport" name="airport"'; echo ' value="' . $p['airport'] . '" />'; if (isset($connects[$p['airport']])) { renderSelect('destination', $connects[$p['airport']], 'Destination'); } echo '</p><p class="otherchoice">Wrong choice? '; echo '<a href="exampleSelectBoxes.php" '; echo 'id="back">Go back one step</a></p>'; } if (isset($p['destination'])) { echo '<h2>Pick the possible flight times and dates - Step 3 of 3</h2>'; echo '<h3>Flights from ' . $p['airport'] . ' to ' . $p['destination'] . '</h3>'; echo '<p>... more server side functionality ...</p>'; echo '<p class="otherchoice">Wrong choice? '; echo '<a href="exampleSelectBoxes.php" id="back">Select again</a></p>'; } /* Helper functions */ function renderSelect($name, $options, $label) {
public function render() { global $base_url; if ($this->render_wrapper) { $this->renderStartTag(); } if ($this->ret) { ?> <input type="hidden" name="r" value="<?php echo $this->ret; ?> " /> <?php } foreach ($this->fields as $field) { $disabled = isset($field->disabled) ? $field->disabled : ''; if ($field->type == 'hidden') { ?> <input type="hidden" name="<?php echo $field->name; ?> " id="field_<?php echo $field->name; ?> " value="<?php echo $field->value; ?> " /> <?php } elseif ($field->type == 'begin_group') { ?> <div class="panel panel-default"> <div class="panel-body"> <?php } elseif ($field->type == 'end_group') { ?> </div> </div> <?php } else { ?> <div class="form-group"> <label for="<?php echo $field->name; ?> " class="col-sm-4 control-label"><?php echo t($field->label); ?> :</label> <div class="col-sm-8"> <?php switch ($field->type) { case 'text': ?> <input type="text" name="<?php echo $field->name; ?> " <?php echo $disabled; ?> value="<?php echo $field->value; ?> " class="form-control" /> <?php break; case 'password': ?> <input type="password" name="<?php echo $field->name; ?> " <?php echo $disabled; ?> value="<?php echo $field->value; ?> " class="form-control" /> <?php break; case 'bool': ?> <input type="checkbox" name="<?php echo $field->name; ?> " <?php echo $disabled; ?> value="1" <?php echo $field->value ? 'checked' : ''; ?> class="form-control form-control-checkbox" /> <?php break; case 'date': ?> <input type="datetime" name="<?php echo $field->name; ?> " <?php echo $disabled; ?> value="<?php echo $field->value; ?> " class="form-control" /> <?php break; case 'file': ?> <input type="file" name="<?php echo $field->name; ?> " <?php echo $disabled; ?> class="form-control-file" /> <?php break; case 'image': global $images; $images->renderImage($field->value, 'mini-thumb'); ?> <input type="hidden" name="<?php echo $field->name; ?> " id="field_<?php echo $field->name; ?> " value="<?php echo $field->value; ?> " /> <input type="file" name="<?php echo $field->name; ?> _image_file" <?php echo $disabled; ?> class="form-control-file" /> <?php break; case 'select': renderSelect($field->name, $field->select_data, $field->select_id_field, $field->select_label_field, $field->value); break; case 'foreign_key_link': ?> <p class="form-control-static"> <?php renderLink($field->link_url, $field->link_label); ?> </p> <?php break; case 'static': ?> <p class="form-control-static"><?php echo $field->value; ?> </p> <?php break; } if (isset($field->validations)) { foreach ($field->validations as $validation) { ?> <div class="form-validation" id="<?php echo $field->name; ?> _validation_<?php echo $validation['type']; ?> "><?php echo isset($validation['message']) ? $validation['message'] : Form::getValidationMessage($validation); ?> </div> <?php } } if (isset($field->hint)) { ?> <small class="text-muted"><?php echo t($field->hint); ?> </small> <?php } ?> </div> </div> <?php } } if ($this->is_admin_form) { ?> <div class="form-buttons"> <a class="form-button" href="<?php echo _url($this->ret); ?> "><?php echo t('Back'); ?> </a> <input type="button" onclick="javascript:deleteItem_<?php echo $this->id; ?> ();" class="btn btn-danger form-button" value="<?php echo t('Delete'); ?> "> <input type="button" onclick="javascript:validateForm_<?php echo $this->id; ?> ();" class="btn btn-success form-button" value="<?php echo t('Save'); ?> "> </div> <script> function deleteItem_<?php echo $this->id; ?> () { if (confirm('<?php echo t('Are you sure to delete this item?'); ?> ')) { document.location = '<?php echo _url($this->del_url, $this->ret); ?> '; } } </script> <?php } if ($this->render_wrapper) { ?> </form> <?php } ?> <script> function validateForm_<?php echo $this->id; ?> () { var frm = new formValidation('form_<?php echo $this->id; ?> '); <?php foreach ($this->fields as $field) { if (isset($field->validations)) { foreach ($field->validations as $val) { ?> frm.add('<?php echo $field->name; ?> ', '<?php echo $val['type']; ?> ', '<?php echo isset($val['param']) ? $val['param'] : 1; ?> '); <?php } } } ?> frm.submit(); } </script> <?php }