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

Extension Development, Mutiple Save Methods

Development and Programming

eurotrash's avatar
eurotrash
7 posts
14 years ago
eurotrash's avatar eurotrash

I am currently building an extension, wondering if it possible to have two forms with two independent save methods. I realize that I could use the save_settings() method for both forms but that solution is a little kludgy.

Example:

<?=form_open('C=addons_extensions'.AMP.'M=save_extension_settings'.AMP.'file=my_extension');?>

Works fine, calls default save method

<?=form_open('C=addons_extensions'.AMP.'M=save_extension_settings'.AMP.'file=my_extension'.AMP.'method=save_second_form_settings');?>

Does not work as intended, calls the same method as the previous form action.

It is possible to do this in an extension?

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

You could use the same base url (your first one) and add an additional GET parameter. Your save_settings() method could just be a router and look something like this:

function save_settings()
{
    return ($this->EE->input->get('method') == 'save_second_form_settings') ? $this->process_two() : $this->process_one() ;
}

Do you see what I’m getting at?

       
eurotrash's avatar
eurotrash
7 posts
14 years ago
eurotrash's avatar eurotrash

Thanks, that’s exactly what I ended up doing.

Was wondering if there was cleaner/EE 2.0 way doing it as it feels a little dirty to me.

Is this just how extensions work? Had I made my plugin a module instead would I be able to map save form actions to any method in my controller?

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team
Is this just how extensions work? Had I made my plugin a module instead would I be able to map save form actions to any method in my controller?

Yes, Extensions are designed to have a single settings screen. You are correct in that a module would give you the ability to create as many forms as needed within the Control Panel. By using the mcp.{module_name}.php file you can build all of that.

You may still need the extension if you’re using a hook though. So you’ll end up with an add-on package containing both an Extension and a Module.

       

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.