CodeIgniter Forums
Form Helper: input image - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Form Helper: input image (/thread-28714.html)



Form Helper: input image - El Forum - 03-19-2010

[eluser]Unknown[/eluser]
This might help you folks!

Extend Form Helper:
Code:
function form_img($data = '', $src = '', $extra = '')
{
  $defaults = array('type' => 'image', 'name' => (( ! is_array($data)) ? $data :

  return "<input "._parse_form_attributes($data, $defaults).$extra." />";
}

Sample Output:
Code:
<input name="some_name" src="path/to/picture.jpg" type="image">



Form Helper: input image - El Forum - 03-23-2010

[eluser]j√°quer[/eluser]
I did come in looking for just this, but I believe your code got cut off. It's supposed to be:

Code:
function form_img($data = '', $src = '', $extra = '')
{
  $defaults = array('type' => 'image', 'name' => (( ! is_array($data)) ? $data : ''), 'src' => $src);

  return "<input "._parse_form_attributes($data, $defaults).$extra." />";
}

And to help people that don't know how to apply this, you have to create an "application/helpers/MY_form_helper.php" with the above code.


Form Helper: input image - El Forum - 03-23-2010

[eluser]Unknown[/eluser]
Oops, I overlooked that. Thanks for spotting and fixing it! Smile