We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Fieldtype Development Question - display_global_settings() form attribute

Development and Programming

Michael Witwicki's avatar
Michael Witwicki
115 posts
14 years ago
Michael Witwicki's avatar Michael Witwicki

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

       
Wes Rice's avatar
Wes Rice
103 posts
14 years ago
Wes Rice's avatar Wes Rice

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;
}
       
Michael Witwicki's avatar
Michael Witwicki
115 posts
14 years ago
Michael Witwicki's avatar Michael Witwicki

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;
}
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.