当前位置: 首页>>代码示例>>PHP>>正文


PHP CI::form_validation方法代码示例

本文整理汇总了PHP中CI::form_validation方法的典型用法代码示例。如果您正苦于以下问题:PHP CI::form_validation方法的具体用法?PHP CI::form_validation怎么用?PHP CI::form_validation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CI的用法示例。


在下文中一共展示了CI::form_validation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: form

 public function form()
 {
     \CI::form_validation()->set_rules('to_email', 'lang:recipient_email', 'trim|required');
     \CI::form_validation()->set_rules('to_name', 'lang:recipient_name', 'trim|required');
     \CI::form_validation()->set_rules('from', 'lang:sender_name', 'trim|required');
     \CI::form_validation()->set_rules('personal_message', 'lang:personal_message', 'trim');
     \CI::form_validation()->set_rules('beginning_amount', 'lang:amount', 'trim|required|numeric');
     $data['page_title'] = lang('add_gift_card');
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('gift_card_form', $data);
     } else {
         $save['code'] = generate_code();
         // from the string helper
         $save['to_email'] = \CI::input()->post('to_email');
         $save['to_name'] = \CI::input()->post('to_name');
         $save['from'] = \CI::input()->post('from');
         $save['personal_message'] = \CI::input()->post('personal_message');
         $save['beginning_amount'] = \CI::input()->post('beginning_amount');
         \CI::GiftCards()->saveCard($save);
         if (\CI::input()->post('sendNotification')) {
             \GoCart\Emails::giftCardNotification($save);
         }
         \CI::session()->set_flashdata('message', lang('message_saved_gift_card'));
         redirect('admin/gift-cards');
     }
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:26,代码来源:AdminGiftCards.php

示例2: forgotPassword

 public function forgotPassword()
 {
     //redirect if the user is already logged in
     $redirect = \CI::auth()->isLoggedIn(false, false);
     if ($redirect) {
         redirect('admin/dashboard');
     }
     \CI::form_validation()->set_rules('username', 'lang:username', ['trim', 'required', ['username_callable', function ($str) {
         $success = \CI::auth()->resetPassword($str);
         if (!$success) {
             \CI::form_validation()->set_message('username_callable', lang('username_doesnt_exist'));
             return FALSE;
         } else {
             //user does exist. and the password is reset.
             return TRUE;
         }
     }]]);
     if (\CI::form_validation()->run() == FALSE) {
         $this->views->show('admin/header');
         $this->views->show('admin/forgot_password');
         $this->views->show('admin/footer');
     } else {
         \CI::session()->set_flashdata('message', lang('password_reset_message'));
         redirect('admin/login');
     }
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:26,代码来源:AdminLogin.php

示例3: form

 public function form()
 {
     //this same function processes the form
     \CI::load()->helper('form');
     \CI::load()->library('form_validation');
     \CI::form_validation()->set_rules('enabled', 'lang:enabled', 'trim|numeric');
     \CI::form_validation()->set_rules('rate', 'lang:rate', 'trim|floatval');
     if (\CI::form_validation()->run() == FALSE) {
         $settings = \CI::Settings()->get_settings('FlatRate');
         $this->view('flat_rate_form', $settings);
     } else {
         \CI::Settings()->save_settings('FlatRate', \CI::input()->post());
         redirect('admin/shipping');
     }
 }
开发者ID:thijmenvenus,项目名称:GoCart3,代码行数:15,代码来源:AdminFlatRate.php

示例4: form

 public function form()
 {
     //this same function processes the form
     \CI::load()->helper('form');
     \CI::load()->library('form_validation');
     \CI::form_validation()->set_rules('enabled', 'lang:enabled', 'trim|numeric');
     if (\CI::form_validation()->run() == FALSE) {
         $settings = \CI::Settings()->get_settings('cod');
         $enabled = $settings['enabled'];
         $this->view('cod_form', ['enabled' => $enabled]);
     } else {
         \CI::Settings()->save_settings('cod', array('enabled' => $_POST['enabled']));
         redirect('admin/payments');
     }
 }
开发者ID:thijmenvenus,项目名称:GoCart3,代码行数:15,代码来源:AdminCod.php

示例5: form

 public function form($id = 0)
 {
     \CI::load()->helper('form_helper');
     \CI::load()->library('form_validation');
     \CI::form_validation()->set_error_delimiters('<div class="error">', '</div>');
     $data = ['id' => '', 'filename' => '', 'max_downloads' => '', 'title' => '', 'size' => ''];
     if ($id) {
         $data = array_merge($data, (array) \CI::DigitalProducts()->getFileInfo($id));
     }
     $data['page_title'] = lang('digital_products_form');
     \CI::form_validation()->set_rules('max_downloads', 'lang:max_downloads', 'numeric');
     \CI::form_validation()->set_rules('title', 'lang:title', 'trim|required');
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('digital_product_form', $data);
     } else {
         if ($id == 0) {
             $data['file_name'] = false;
             $data['error'] = false;
             $config['allowed_types'] = '*';
             $config['upload_path'] = 'uploads/digital_products';
             //config_item('digital_products_path');
             $config['remove_spaces'] = true;
             \CI::load()->library('upload', $config);
             if (\CI::upload()->do_upload()) {
                 $upload_data = \CI::upload()->data();
             } else {
                 $data['error'] = \CI::upload()->display_errors();
                 $this->view('digital_product_form', $data);
                 return;
             }
             $save['filename'] = $upload_data['file_name'];
             $save['size'] = $upload_data['file_size'];
         } else {
             $save['id'] = $id;
         }
         $save['max_downloads'] = \CI::input()->post('max_downloads');
         $save['title'] = \CI::input()->post('title');
         \CI::DigitalProducts()->save($save);
         redirect('admin/digital_products');
     }
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:41,代码来源:AdminDigitalProducts.php

示例6: forgotPassword

 public function forgotPassword()
 {
     $data['page_title'] = lang('forgot_password');
     $submitted = \CI::input()->post('submitted');
     \CI::form_validation()->set_rules('email', 'lang:address_email', ['trim', 'required', 'valid_email', ['email_callable', function ($str) {
         $reset = \CI::Customers()->reset_password($str);
         if (!$reset) {
             \CI::form_validation()->set_message('email_callable', lang('error_no_account_record'));
             return FALSE;
         } else {
             //user does exist. and the password is reset.
             return TRUE;
         }
     }]]);
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('forgot_password', $data);
     } else {
         \CI::session()->set_flashdata('message', lang('message_new_password'));
         redirect('login');
     }
 }
开发者ID:haouach,项目名称:GoCart3,代码行数:21,代码来源:Login.php

示例7: check_email

 public function check_email($str)
 {
     $email = \CI::Customers()->check_email($str);
     if ($email) {
         \CI::form_validation()->set_message('check_email_callable', lang('error_email'));
         return FALSE;
     } else {
         return TRUE;
     }
 }
开发者ID:haouach,项目名称:GoCart3,代码行数:10,代码来源:Register.php

示例8: function

            $.post($(this).attr('action'), $(this).serialize(), function(data){
                if(data === 1)
                {
                    closeAddressForm();
                }
                else
                {
                    $('#addressFormWrapper').html(data);
                }
            });
        })
    });

    <?php 
if (validation_errors()) {
    $errors = \CI::form_validation()->get_error_array();
    ?>

        var formErrors = <?php 
    echo json_encode($errors);
    ?>
        
        for (var key in formErrors) {
            if (formErrors.hasOwnProperty(key)) {
                $('[name="'+key+'"]').parent().append('<div class="form-error text-red">'+formErrors[key]+'</div>')
            }
        }
    <?php 
}
?>
    </script>
开发者ID:alextoshinov,项目名称:musymeshop,代码行数:31,代码来源:address_form.php

示例9: zone_area_form

 public function zone_area_form($zone_id, $area_id = false)
 {
     \CI::load()->helper('form');
     \CI::load()->library('form_validation');
     \CI::form_validation()->set_error_delimiters('<div class="error">', '</div>');
     $zone = \CI::Locations()->get_zone($zone_id);
     $data['zone'] = $zone;
     //default values are empty if the product is new
     $data['id'] = '';
     $data['code'] = '';
     $data['zone_id'] = $zone_id;
     $data['tax'] = 0;
     if ($area_id) {
         $area = (array) \CI::Locations()->get_zone_area($area_id);
         //if the country does not exist, redirect them to the country list with an error
         if (!$area) {
             \CI::session()->set_flashdata('error', lang('error_zone_area_not_found'));
             redirect('admin/locations/zone_areas/' . $zone_id);
         }
         $data = array_merge($data, $area);
     }
     \CI::form_validation()->set_rules('code', 'lang:code', 'trim|required');
     \CI::form_validation()->set_rules('tax', 'lang:tax', 'trim|numeric');
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('country_zone_area_form', $data);
     } else {
         $save['id'] = $area_id;
         $save['zone_id'] = $zone_id;
         $save['code'] = \CI::input()->post('code');
         $save['tax'] = \CI::input()->post('tax');
         \CI::Locations()->save_zone_area($save);
         \CI::session()->set_flashdata('message', lang('message_saved_zone_area'));
         //go back to the product list
         redirect('admin/locations/zone_areas/' . $save['zone_id']);
     }
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:36,代码来源:AdminLocations.php

示例10: form

 public function form($id = false)
 {
     \CI::load()->helper(array('form', 'date'));
     \CI::load()->library('form_validation');
     \CI::form_validation()->set_error_delimiters('<div class="error">', '</div>');
     $this->coupon_id = $id;
     $data['page_title'] = lang('coupon_form');
     //default values are empty if the product is new
     $data['id'] = '';
     $data['code'] = '';
     $data['start_date'] = '';
     $data['whole_order_coupon'] = 0;
     $data['max_product_instances'] = '';
     $data['end_date'] = '';
     $data['max_uses'] = '';
     $data['reduction_type'] = '';
     $data['reduction_amount'] = '';
     $data['products'] = [];
     if ($id) {
         $coupon = \CI::Coupons()->getCoupon($id);
         //if the product does not exist, redirect them to the product list with an error
         if (!$coupon) {
             \CI::session()->set_flashdata('message', lang('error_not_found'));
             redirect('admin/product');
         }
         //set values to db values
         $data['id'] = $coupon->id;
         $data['code'] = $coupon->code;
         $data['start_date'] = $coupon->start_date;
         $data['end_date'] = $coupon->end_date;
         $data['whole_order_coupon'] = $coupon->whole_order_coupon;
         $data['max_product_instances'] = $coupon->max_product_instances;
         $data['num_uses'] = $coupon->num_uses;
         $data['max_uses'] = $coupon->max_uses;
         $data['reduction_type'] = $coupon->reduction_type;
         $data['reduction_amount'] = $coupon->reduction_amount;
         $data['products'] = \CI::Coupons()->getProducts($id);
     }
     \CI::form_validation()->set_rules('code', 'lang:code', ['trim', 'required', ['code_callable', function ($str) {
         $code = \CI::Coupons()->checkCode($str, $this->coupon_id);
         if ($code) {
             \CI::form_validation()->set_message('code_callable', lang('error_already_used'));
             return FALSE;
         } else {
             return TRUE;
         }
     }]]);
     \CI::form_validation()->set_rules('max_uses', 'lang:max_uses', 'trim|numeric');
     \CI::form_validation()->set_rules('max_product_instances', 'lang:limit_per_order', 'trim|numeric');
     \CI::form_validation()->set_rules('whole_order_coupon', 'lang:whole_order_discount');
     \CI::form_validation()->set_rules('reduction_type', 'lang:reduction_type', 'trim');
     \CI::form_validation()->set_rules('reduction_amount', 'lang:reduction_amount', 'trim|numeric');
     \CI::form_validation()->set_rules('start_date', 'lang:start_date');
     \CI::form_validation()->set_rules('end_date', 'lang:end_date');
     if (\CI::form_validation()->run() == FALSE) {
         if (\CI::input()->post()) {
             $data['products'] = json_decode(json_encode(\CI::input()->post('product')));
         }
         $this->view('coupon_form', $data);
     } else {
         $save['id'] = $id;
         $save['code'] = \CI::input()->post('code');
         $save['start_date'] = \CI::input()->post('start_date');
         $save['end_date'] = \CI::input()->post('end_date');
         $save['max_uses'] = \CI::input()->post('max_uses');
         $save['whole_order_coupon'] = \CI::input()->post('whole_order_coupon');
         $save['max_product_instances'] = \CI::input()->post('max_product_instances');
         $save['reduction_type'] = \CI::input()->post('reduction_type');
         $save['reduction_amount'] = \CI::input()->post('reduction_amount');
         if ($save['start_date'] == '') {
             $save['start_date'] = null;
         }
         if ($save['end_date'] == '') {
             $save['end_date'] = null;
         }
         $products = \CI::input()->post('product');
         // save coupon
         $id = \CI::Coupons()->save($save);
         \CI::Coupons()->removeProduct($id);
         if (!$save['whole_order_coupon'] && $products) {
             \CI::Coupons()->addProducts($id, $products);
         }
         // We're done
         \CI::session()->set_flashdata('message', lang('message_saved_coupon'));
         //go back to the product list
         redirect('admin/coupons');
     }
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:88,代码来源:AdminCoupons.php

示例11: form

 public function form($id = false)
 {
     \CI::load()->helper('form');
     \CI::load()->library('form_validation');
     \CI::form_validation()->set_error_delimiters('<div class="error">', '</div>');
     $data['page_title'] = lang('admin_form');
     //default values are empty if the customer is new
     $data['id'] = '';
     $data['firstname'] = '';
     $data['lastname'] = '';
     $data['email'] = '';
     $data['username'] = '';
     $data['access'] = '';
     if ($id) {
         $this->admin_id = $id;
         $admin = \CI::auth()->getAdmin($id);
         //if the administrator does not exist, redirect them to the admin list with an error
         if (!$admin) {
             \CI::session()->set_flashdata('message', lang('admin_not_found'));
             redirect('admin/users');
         }
         //set values to db values
         $data['id'] = $admin->id;
         $data['firstname'] = $admin->firstname;
         $data['lastname'] = $admin->lastname;
         $data['email'] = $admin->email;
         $data['username'] = $admin->username;
         $data['access'] = $admin->access;
     }
     \CI::form_validation()->set_rules('firstname', 'lang:firstname', 'trim|max_length[32]');
     \CI::form_validation()->set_rules('lastname', 'lang:lastname', 'trim|max_length[32]');
     \CI::form_validation()->set_rules('email', 'lang:email', 'trim|required|valid_email|max_length[128]');
     \CI::form_validation()->set_rules('username', 'lang:username', ['trim', 'required', 'max_length[128]', ['username_callable', function ($str) {
         $email = \CI::auth()->check_username($str, $this->admin_id);
         if ($email) {
             \CI::form_validation()->set_message('username_callable', lang('error_username_taken'));
             return FALSE;
         } else {
             return TRUE;
         }
     }]]);
     \CI::form_validation()->set_rules('access', 'lang:access', 'trim|required');
     //if this is a new account require a password, or if they have entered either a password or a password confirmation
     if (\CI::input()->post('password') != '' || \CI::input()->post('confirm') != '' || !$id) {
         \CI::form_validation()->set_rules('password', 'lang:password', 'required|min_length[6]|sha1');
         \CI::form_validation()->set_rules('confirm', 'lang:confirm_password', 'required|sha1|matches[password]');
     }
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('user_form', $data);
     } else {
         $save['id'] = $id;
         $save['firstname'] = \CI::input()->post('firstname');
         $save['lastname'] = \CI::input()->post('lastname');
         $save['email'] = \CI::input()->post('email');
         $save['username'] = \CI::input()->post('username');
         $save['access'] = \CI::input()->post('access');
         if (\CI::input()->post('password') != '' || !$id) {
             $save['password'] = \CI::input()->post('password');
         }
         \CI::auth()->save($save);
         \CI::session()->set_flashdata('message', lang('message_user_saved'));
         //go back to the customer list
         redirect('admin/users');
     }
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:65,代码来源:AdminUsers.php

示例12: addressForm

 public function addressForm($customer_id, $id = false)
 {
     $data['id'] = $id;
     $data['company'] = '';
     $data['firstname'] = '';
     $data['lastname'] = '';
     $data['email'] = '';
     $data['phone'] = '';
     $data['address1'] = '';
     $data['address2'] = '';
     $data['city'] = '';
     $data['country_id'] = '';
     $data['zone_id'] = '';
     $data['zip'] = '';
     $data['customer_id'] = $customer_id;
     $data['page_title'] = lang('address_form');
     //get the countries list for the dropdown
     $data['countries_menu'] = \CI::Locations()->get_countries_menu();
     if ($id) {
         $address = \CI::Customers()->get_address($id);
         //fully escape the address
         form_decode($address);
         //merge the array
         $data = array_merge($data, $address);
         $data['zones_menu'] = \CI::Locations()->get_zones_menu($data['country_id']);
     } else {
         //if there is no set ID, the get the zones of the first country in the countries menu
         $country_keys = array_keys($data['countries_menu']);
         $data['zones_menu'] = \CI::Locations()->get_zones_menu(array_shift($country_keys));
     }
     \CI::load()->library('form_validation');
     \CI::form_validation()->set_rules('company', 'lang:company', 'trim|max_length[128]');
     \CI::form_validation()->set_rules('firstname', 'lang:firstname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('lastname', 'lang:lastname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('email', 'lang:email', 'trim|required|valid_email|max_length[128]');
     \CI::form_validation()->set_rules('phone', 'lang:phone', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('address1', 'lang:address', 'trim|required|max_length[128]');
     \CI::form_validation()->set_rules('address2', 'lang:address', 'trim|max_length[128]');
     \CI::form_validation()->set_rules('city', 'lang:city', 'trim|required');
     \CI::form_validation()->set_rules('country_id', 'lang:country', 'trim|required');
     \CI::form_validation()->set_rules('zone_id', 'lang:state', 'trim|required');
     \CI::form_validation()->set_rules('zip', 'lang:zip', 'trim|required|max_length[32]');
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('customer_address_form', $data);
     } else {
         $a['customer_id'] = $customer_id;
         // this is needed for new records
         $a['id'] = empty($id) ? '' : $id;
         $a['field_data']['company'] = \CI::input()->post('company');
         $a['field_data']['firstname'] = \CI::input()->post('firstname');
         $a['field_data']['lastname'] = \CI::input()->post('lastname');
         $a['field_data']['email'] = \CI::input()->post('email');
         $a['field_data']['phone'] = \CI::input()->post('phone');
         $a['field_data']['address1'] = \CI::input()->post('address1');
         $a['field_data']['address2'] = \CI::input()->post('address2');
         $a['field_data']['city'] = \CI::input()->post('city');
         $a['field_data']['zip'] = \CI::input()->post('zip');
         $a['field_data']['zone_id'] = \CI::input()->post('zone_id');
         $a['field_data']['country_id'] = \CI::input()->post('country_id');
         $country = \CI::Locations()->get_country(\CI::input()->post('country_id'));
         $zone = \CI::Locations()->get_zone(\CI::input()->post('zone_id'));
         $a['field_data']['zone'] = $zone->code;
         // save the state for output formatted addresses
         $a['field_data']['country'] = $country->name;
         // some shipping libraries require country name
         $a['field_data']['country_code'] = $country->iso_code_2;
         // some shipping libraries require the code
         \CI::Customers()->save_address($a);
         \CI::session()->set_flashdata('message', lang('message_saved_address'));
         redirect('admin/customers/addresses/' . $customer_id);
     }
 }
开发者ID:thijmenvenus,项目名称:GoCart3,代码行数:72,代码来源:AdminCustomers.php

示例13: link_form

 function link_form($id = false)
 {
     //set the default values
     $data['id'] = '';
     $data['title'] = '';
     $data['url'] = '';
     $data['new_window'] = false;
     $data['sequence'] = 0;
     $data['parent_id'] = 0;
     $data['page_title'] = lang('link_form');
     $data['pages'] = \CI::Pages()->get_pages();
     if ($id) {
         $page = \CI::Pages()->find($id);
         if (!$page) {
             //page does not exist
             \CI::session()->set_flashdata('error', lang('error_link_not_found'));
             redirect('admin/pages');
         }
         //set values to db values
         $data['id'] = $page->id;
         $data['parent_id'] = $page->parent_id;
         $data['title'] = $page->title;
         $data['url'] = $page->url;
         $data['new_window'] = (bool) $page->new_window;
         $data['sequence'] = $page->sequence;
     }
     \CI::form_validation()->set_rules('title', 'lang:title', 'trim|required');
     \CI::form_validation()->set_rules('url', 'lang:url', 'trim|required');
     \CI::form_validation()->set_rules('sequence', 'lang:sequence', 'trim|integer');
     \CI::form_validation()->set_rules('new_window', 'lang:new_window', 'trim|integer');
     \CI::form_validation()->set_rules('parent_id', 'lang:parent_id', 'trim|integer');
     // Validate the form
     if (\CI::form_validation()->run() == false) {
         $this->view('link_form', $data);
     } else {
         $save = [];
         $save['id'] = $id;
         $save['parent_id'] = \CI::input()->post('parent_id');
         $save['title'] = \CI::input()->post('title');
         $save['menu_title'] = \CI::input()->post('title');
         $save['url'] = \CI::input()->post('url');
         $save['sequence'] = \CI::input()->post('sequence');
         $save['new_window'] = (bool) \CI::input()->post('new_window');
         //save the page
         \CI::Pages()->save($save);
         \CI::session()->set_flashdata('message', lang('message_saved_link'));
         //go back to the page list
         redirect('admin/pages');
     }
 }
开发者ID:haouach,项目名称:GoCart3,代码行数:50,代码来源:AdminPages.php

示例14: form

 public function form($id = 0)
 {
     $data['addressCount'] = \CI::Customers()->count_addresses($this->customer->id);
     $customer = \CI::Login()->customer();
     //grab the address if it's available
     $data['id'] = false;
     $data['firstname'] = $customer->firstname;
     $data['lastname'] = $customer->lastname;
     $data['email'] = $customer->email;
     $data['phone'] = $customer->phone;
     $data['address1'] = '';
     $data['address2'] = '';
     $data['city'] = '';
     $data['country_id'] = '';
     $data['zone_id'] = '';
     $data['zip'] = '';
     if ($id != 0) {
         $a = \CI::Customers()->get_address($id);
         if ($a['customer_id'] != $this->customer->id) {
             redirect('addresses/form');
             // don't allow cross-customer editing
         }
         $data = array_merge($data, $a);
         $data['zones_menu'] = \CI::Locations()->get_zones_menu($data['country_id']);
     }
     //get the countries list for the dropdown
     $data['countries_menu'] = \CI::Locations()->get_countries_menu();
     if ($id == 0) {
         //if there is no set ID, the get the zones of the first country in the countries menu
         $data['zones_menu'] = \CI::Locations()->get_zones_menu(array_shift(array_keys($data['countries_menu'])));
     } else {
         $data['zones_menu'] = \CI::Locations()->get_zones_menu($data['country_id']);
     }
     \CI::load()->library('form_validation');
     //        \CI::form_validation()->set_rules('company', 'lang:address_company', 'trim|max_length[128]');
     \CI::form_validation()->set_rules('firstname', 'lang:address_firstname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('lastname', 'lang:address_lastname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('email', 'lang:address_email', 'trim|required|valid_email|max_length[128]');
     \CI::form_validation()->set_rules('phone', 'lang:address_phone', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('address1', 'lang:address', 'trim|required|max_length[128]');
     \CI::form_validation()->set_rules('address2', 'lang:address2', 'trim|max_length[128]');
     \CI::form_validation()->set_rules('city', 'lang:address_city', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('country_id', 'lang:address_country', 'trim|required|numeric');
     \CI::form_validation()->set_rules('zone_id', 'lang:address_state', 'trim|required|numeric');
     \CI::form_validation()->set_rules('zip', 'lang:address_zip', 'trim|required|max_length[32]');
     if (\CI::form_validation()->run() == FALSE) {
         $this->partial('address_form', $data);
     } else {
         $a = [];
         $a['id'] = $id == 0 ? '' : $id;
         $a['customer_id'] = $this->customer->id;
         $a['firstname'] = \CI::input()->post('firstname');
         $a['lastname'] = \CI::input()->post('lastname');
         $a['email'] = \CI::input()->post('email');
         $a['phone'] = \CI::input()->post('phone');
         $a['address1'] = \CI::input()->post('address1');
         $a['address2'] = \CI::input()->post('address2');
         $a['city'] = \CI::input()->post('city');
         $a['zip'] = \CI::input()->post('zip');
         // get zone / country data using the zone id submitted as state
         $country = \CI::Locations()->get_country(assign_value('country_id'));
         $zone = \CI::Locations()->get_zone(assign_value('zone_id'));
         if (!empty($country)) {
             $a['zone'] = $zone->code;
             // save the state for output formatted addresses
             $a['country'] = $country->name;
             // some shipping libraries require country name
             $a['country_code'] = $country->iso_code_2;
             // some shipping libraries require the code
             $a['country_id'] = \CI::input()->post('country_id');
             $a['zone_id'] = \CI::input()->post('zone_id');
         }
         \CI::Customers()->save_address($a);
         echo 1;
     }
 }
开发者ID:alextoshinov,项目名称:musymeshop,代码行数:76,代码来源:Addresses.php

示例15: canned_message_form

 public function canned_message_form($id = false)
 {
     $data['page_title'] = lang('canned_message_form');
     $data['id'] = $id;
     $data['name'] = '';
     $data['subject'] = '';
     $data['content'] = '';
     $data['deletable'] = 1;
     if ($id) {
         $message = \CI::Messages()->get_message($id);
         $data = array_merge($data, $message);
     }
     \CI::load()->helper('form');
     \CI::load()->library('form_validation');
     \CI::form_validation()->set_rules('name', 'lang:message_name', 'trim|required|max_length[50]');
     \CI::form_validation()->set_rules('subject', 'lang:subject', 'trim|required|max_length[100]');
     \CI::form_validation()->set_rules('content', 'lang:message_content', 'trim|required');
     if (\CI::form_validation()->run() == FALSE) {
         $data['errors'] = validation_errors();
         $this->view('canned_message_form', $data);
     } else {
         $save['id'] = $id;
         $save['name'] = \CI::input()->post('name');
         $save['subject'] = \CI::input()->post('subject');
         $save['content'] = \CI::input()->post('content');
         //all created messages are typed to order so admins can send them from the view order page.
         if ($data['deletable']) {
             $save['type'] = 'order';
         }
         \CI::Messages()->save_message($save);
         \CI::session()->set_flashdata('message', lang('message_saved_message'));
         redirect('admin/settings/canned_messages');
     }
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:34,代码来源:AdminSettings.php


注:本文中的CI::form_validation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。