Hey guys and gals,
Developing a new fieldtype - and for one of my global settings, I want to be allow the user to upload a file. However, I don’t see a clear way to add the enctype=”multipart/form-data” attribute to the form created by display_global_settings(). Can someone please point me in the right direction?
Thanks in advance,
Michael Witwicki
I see what you mean. It appears the form_open() method is predefined and all you are able to control is the content within the form.
Here are two ideas off the top of my head.
1) Perhaps you can use jquery to add enctype=”multipart/form-data” to the form? I know that is less than ideal, but it might be the easiest way to add the attribute.
2) What if you immediately close the form and then open a new one? You would need to redefine the path and attributes of the form though. It might be worth a shot.
function display_global_settings()
{
$val = array_merge($this->settings, $_POST);
$form = form_close();
$form .= form_open_multipart('path/to/action', $attributes);
$form .= form_label('latitude', 'latitude').NBS.form_input('latitude', $val['latitude']).NBS.NBS.NBS.' ';
return $form;
}Hey Wes!
Thank you so much for the ideas - I am HOPING that I won’t have to hack this to make it work, but if it comes to that, I think I’ll probably go with the jQuery method (to avoid any errors potentially caused by future updates, etc). Like you said, not IDEAL, but it will do the trick.
I really appreciate the feedback!!
Michael
I see what you mean. It appears the form_open() method is predefined and all you are able to control is the content within the form. Here are two ideas off the top of my head. 1) Perhaps you can use jquery to add enctype=”multipart/form-data” to the form? I know that is less than ideal, but it might be the easiest way to add the attribute. 2) What if you immediately close the form and then open a new one? You would need to redefine the path and attributes of the form though. It might be worth a shot.function display_global_settings() { $val = array_merge($this->settings, $_POST); $form = form_close(); $form .= form_open_multipart('path/to/action', $attributes); $form .= form_label('latitude', 'latitude').NBS.form_input('latitude', $val['latitude']).NBS.NBS.NBS.' '; return $form; }
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.