/** * Internal funcion. Every form based request/response should include an * authenticity token to prevent CSRF. This function gets the current token * for the current response. * * @returns A string representing the authenticty token for this response. */ public static function get_request_token() { if (null == self::$token) { self::$token = sha1(time() . Config::get("form.authenticity_salt")); $_SESSION['_xoket_authenticity_token'] = self::$token; } return self::$token; }
<?php $html = ''; if (is_array($data) && !empty($data)) { $sort = array('ASC' => 'Ascending', 'DESC' => 'Descending'); $html .= '<form data-ajax-form data-action="filter_hotel_list" data-target="filter_hotels">'; $html .= '<ul class="inline">'; $html .= '<li><select name="hotel_sort" data-fireable-input>' . Form_Helper::options_for_select($sort, null, null) . '</select></li>'; $html .= '<li><select name="hotel_type" data-fireable-input>' . Form_Helper::options_for_select($data['hotel_types'], null, 'Hotel Type') . '</select></li>'; $html .= '</ul>'; $html .= '</form>'; } echo $html;
<?php require_once '../../functions.php'; $data = $_POST; $resp = new Ajax_Response($data['action'], true); if (!empty($data) && is_array($data)) { // $data['product_type'] $ingredient_type = new Ingredient_Type($data['type']); $ingredient = new Ingredient(); $options = $ingredient->get_ingredients_by_type($ingredient_type->ingredient_type_id); if (is_array($options) && !empty($options)) { $data['type'] = 'select'; $data['name'] = 'ingredients[' . $ingredient_type->ingredient_type_slug . ']'; $data['val'] = $options; $data['data_attr'] = ''; $data['placeholder'] = 'Select an Ice Cream Flavor'; $resp->set_status(true); $resp->set_data(array('field' => Form_Helper::build_field($data))); } else { $resp->set_message('Could not load field. Sorry, <a href="#" data-ajax-get data-action="add_field" data-extra-data="ice_cream">try again</a>?'); } } echo $resp->encode_response(); die;
public function all_hotels_options() { $hotels = array(); $loop = new WP_Query(array('post_type' => 'hotel', 'posts_per_page' => '-1')); if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); $hotels[$loop->post->ID] = $loop->post->post_title; } } return Form_Helper::options_for_select($hotels, '', 'Select a Hotel'); }
<div class="panel-header"><legend>Basic Hotel Details</legend></div> <div class="panel-content"> <ul> <li class="half"> <label>Hotel Name:</label> <input type="text" name="hotel[hotel_name]" value="<?php echo $hotel->hotel_name; ?> " placeholder="Hotel Name" /> </li> <li class="half right"> <label>Hotel Type:</label> <select name="hotel[hotel_type]"> <?php echo Form_Helper::options_for_select($types, $hotel->hotel_type); ?> </select> </li> <li class="full"> <label>Hotel Email:</label> <input type="text" name="hotel[hotel_email_address]" value="<?php echo $hotel->hotel_email_address; ?> " placeholder="Hotel Email" /> </li> <li class="third"> <label>Hotel Phone Number:</label> <input type="text" name="hotel[hotel_phone_number]" value="<?php
?> <div class="wrap main-body"> <a href="#" data-flyout-trigger data-async-content="load_cart_count"><i class="fa fa-fw fa-shopping-cart"></i><?php $cart->cart_item_count_string(); ?> </a> <div class="table" data-loader><div class="table-cell"><i class="fa fa-spin fa-cog"></i></div></div> <div class="wrapper table"> <div class="table-cell"> <header><h1>SoftServer</h1></header> <div class="active fadein" data-main-content data-updateable-content="order-form"> <form data-ajax-form data-action="choose_product_type" data-target="order-form"> <select data-ajax-select name="product_type"> <?php echo Form_Helper::build_select_options($product_type->types, 'What can I get ya?'); ?> </select> </form> </div> </div> </div> </div> <div class="wrap cart" data-flyout > <div class="wrapper cart-header"> <h3>Your Cart</h3> <a href="#" data-destroy-flyout><i class="fa fa-fw fa-times"></i></a> </div> <div class="wrapper cart-body" data-async-content="load_cart_data" data-load-when="deferred" data-target="cart-contents"> <?php echo $cart->get_cart_contents();
/** * get_product_form_fields function. * * @access public * @param Product_Type $product_type * @return void */ public function get_product_form_fields(Product_Type $product_type) { $fields = ''; $ingredient = new Ingredient(); if ($product_type->product_type_slug != null) { $ingredient->get_ingredients_by_type(1); switch ($product_type->product_type_slug) { case 'cone': $ingredients = $ingredient->get_ingredients_by_type(4); unset($ingredients[18]); $fields .= '<input type="hidden" name="product_type" value="' . $product_type->product_type_id . '" /> <li> <select name="ingredients[container]"> ' . Form_Helper::build_select_options($ingredients, 'Select a Cone Type') . ' </select> </li> <li> <label>Scoop #1</label> <select name="ingredients[ice_cream][]"> ' . Form_Helper::build_select_options($ingredient->get_ingredients_by_type(1), 'Select 1st Ice Cream Flavor') . ' </select> </li> <li> <label>Scoop #2</label> <select name="ingredients[ice_cream][]"> ' . Form_Helper::build_select_options($ingredient->get_ingredients_by_type(1), 'Select 2nd Ice Cream Flavor') . ' </select> </li>'; //<li class="submit"><a href="#" data-ajax-get data-action="add_field" data-extra-data="ice_cream">Add Another Flavor!</a></li> break; case 'milkshake': $fields .= '<input type="hidden" name="product_type" value="' . $product_type->product_type_id . '" /> <li> <h4>Use Promo Code DOLLAROFF for a discount!</h4> <input type="hidden" name="ingredients[container]" value="18" /> </li> <li> <select name="ingredients[ice_cream]"> ' . Form_Helper::build_select_options($ingredient->get_ingredients_by_type(1), 'Select an Ice Cream Flavor') . ' </select> </li> <li> <select name="ingredients[milk][]"> ' . Form_Helper::build_select_options($ingredient->get_ingredients_by_type(3), 'Select Milk Type') . ' </select> </li>'; break; case 'float': $fields .= '<input type="hidden" name="product_type" value="' . $product_type->product_type_id . '" /> <li> <h4>Use Promo Code DOLLAROFF for a discount!</h4> <input type="hidden" name="ingredients[container]" value="18" /> </li> <li> <select name="ingredients[soda][]"> ' . Form_Helper::build_select_options($ingredient->get_ingredients_by_type(2), 'Select a Soda') . ' </select> </li> <li> <label>Scoop #1</label> <select name="ingredients[ice_cream][]"> ' . Form_Helper::build_select_options($ingredient->get_ingredients_by_type(1), 'Select an Ice Cream Flavor') . ' </select> </li> <li class="submit"><a href="#" data-ajax-get data-action="add_field" data-extra-data="ice_cream">Add Another Flavor!</a></li>'; break; } } return $fields; }
</li> <li class="third "> <label>CC Exp:</label> <select name="reservation[guest_credit_card_expiration_month]"> <?php echo Form_Helper::cc_exp_months($reserv->reservation_guest_credit_card_expiration_month); ?> </select> </li> <li class="third "> <label>CC Exp:</label> <select name="reservation[guest_credit_card_expiration_year]"> <?php echo Form_Helper::cc_exp_year($reserv->reservation_guest_credit_card_expiration_year); ?> </select> </li> <li class="third right"> <label>Security Code:</label> <input type="text" name="reservation[guest_credit_card_number_security_code]" value="<?php echo $reserv->reservation_guest_credit_card_security_code; ?> " /> </li> </ul> </div>