0

I am building a custom plugin to process a form. I am new to custom plugins and after looking at several different tutorials I am stuck on my form action. I would like to access the process form method in the class, is this correct with EE and if so, how do I go about it.

Thanks.

class Myform {

public function __construct()
{
    $this->EE =& get_instance();
}

public function form()
{

    $form_data = array(
        "id"    => $this->EE->TMPL->form_id,
        "class" => $this->EE->TMPL->form_class,
        "action" => //process_form()
    );

    $tagdata = $this->EE->TMPL->tagdata;

    $form = $this->EE->functions->form_declaration($form_data) . $tagdata . "</form>";

    return $form;
}

public function process_form()
{
    return "testing";
}
// --------------------------------------------------------------------

/**
 * Usage
 *
 * Plugin Usage
 *
 * @access  public
 * @return  string
 */
function usage()
{
    ob_start(); 
    ?>

    Documentation will go here

    <?php
    $buffer = ob_get_contents();

    ob_end_clean(); 

    return $buffer;
}

// --------------------------------------------------------------------

} // END CLASS

2

You create a plugin or module? Because actions is using in Modules. You can add new action to the system using next query (usually in function install):

$sql[] = "INSERT INTO exp_actions (class, method) VALUES ('module_name', 'my_action_procedure')";

how to get action id for specific method:

 $form_data = array(
        "id"    => $this->EE->TMPL->fetch_param('form_id',''),
        "class" => $this->EE->TMPL->fetch_param('form_class',''),
        "action" => ee()->functions->fetch_action_id('module_name', 'process_form');
    );

if you don't want to develop module, just give user option to add another template name as base for processing form, like

{ext:myform process_uri="home/process" form_id="my-form" form_class="super-form-class"}

home/process

{ext:my_plugin:process_form}
| improve this answer | |
  • $actionID = ee()->functions->fetch_action_id(CLASS, 'process_form'); is better than a custom active record query. – Peter Lewis Feb 10 '14 at 9:08
  • agree. always forgot about this :) – Max Lazar Feb 10 '14 at 9:13
  • rebuilding as module, let me catch up and I'll follow up – SuperNinja Feb 10 '14 at 18:38
  • @MaxLazar - thanks for the suggestion on the module. Built successfully! I will accept your answer. One more question or just tell me to ask a new..currently after successful post I am using the default message $this->EE->output->show_message($data); Is there a way instead to redirect with the $data to new page or should I set up tags? thanks – SuperNinja Feb 11 '14 at 6:21
  • @Bungdaddy - how did you get on with redirecting with the data? I'm also wanting to do that. – Jim Pannell Sep 2 '14 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.