diff options
author | Derek Allard <derek.allard@ellislab.com> | 2009-09-16 10:20:58 +0200 |
---|---|---|
committer | Derek Allard <derek.allard@ellislab.com> | 2009-09-16 10:20:58 +0200 |
commit | 928158bf3a308330ab6518ff0d149d4585d7f38f (patch) | |
tree | a956e0e0075bee87a13fb55260d5aab51dd26e66 | |
parent | bbedc76aaf59f6f12a7bc32e1aa851317a61c837 (diff) |
adding accept-charset to form_open()
-rw-r--r-- | system/helpers/form_helper.php | 23 | ||||
-rw-r--r-- | user_guide/changelog.html | 8 | ||||
-rw-r--r-- | user_guide/helpers/form_helper.html | 8 |
3 files changed, 34 insertions, 5 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index c5e977a40..2fd4807fc 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -44,9 +44,30 @@ if ( ! function_exists('form_open')) { $CI =& get_instance(); + $charset = strtolower($CI->config->item('charset')); + if ($attributes == '') { - $attributes = 'method="post"'; + $attributes = 'method="post" accept-charset="'.$charset.'"'; + } + else + { + if ( is_string($attributes) ) + { + if(strpos('accept-charset=') === FALSE) + { + $attributes .= ' accept-charset="'.$charset.'"'; + } + } + else + { + $attributes = (array) $attributes; + + if(!in_array('accept-charset', $attributes)) + { + $attributes['accept-charset'] = $charset; + } + } } $action = ( strpos($action, '://') === FALSE) ? $CI->config->site_url($action) : $action; diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 3060fe9b1..d23d92056 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -61,6 +61,14 @@ Change Log <p>Release Date: not yet released<br /> SVN Revision: </p> +<ul> + <li>Helpers + <ul> + <li>Added accept-charset to the list of inserted attributes of <kbd>form_open()</kbd> in the <a href="helpers/form_helper.html">Form Helper</a>.</li> + </ul> + </li> +</ul> + <h2>Version 1.7.2</h2> <p>Release Date: September 11, 2009<br /> SVN Revision: 1737</p> diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html index 79285970d..4ddde6222 100644 --- a/user_guide/helpers/form_helper.html +++ b/user_guide/helpers/form_helper.html @@ -73,7 +73,7 @@ Form Helper <h2>form_open()</h2> <p>Creates an opening form tag with a base URL <strong>built from your config preferences</strong>. It will optionally let you -add form attributes and hidden input fields.</p> +add form attributes and hidden input fields, and will always add the attribute <kbd>accept-charset</kbd> based on the charset value in your config file.</p> <p>The main benefit of using this tag rather than hard coding your own HTML is that it permits your site to be more portable in the event your URLs ever change.</p> @@ -84,7 +84,7 @@ in the event your URLs ever change.</p> <p>The above example would create a form that points to your base URL plus the "email/send" URI segments, like this:</p> -<code><form method="post" action="http:/example.com/index.php/email/send" /></code> +<code><form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send" /></code> <h4>Adding Attributes</h4> @@ -97,7 +97,7 @@ echo form_open('email/send', $attributes);</code> <p>The above example would create a form similar to this:</p> -<code><form method="post" action="http:/example.com/index.php/email/send" class="email" id="myform" /></code> +<code><form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send" class="email" id="myform" /></code> <h4>Adding Hidden Input Fields</h4> @@ -110,7 +110,7 @@ echo form_open('email/send', '', $hidden);</code> <p>The above example would create a form similar to this:</p> -<code><form method="post" action="http:/example.com/index.php/email/send"><br /> +<code><form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send"><br /> <input type="hidden" name="username" value="Joe" /><br /> <input type="hidden" name="member_id" value="234" /></code> |