Torro Forms // Using Form Result API

For adding your own settings, the classTorro_Form_Result have to be extended by your own class.

The Torro Form results API adds a Tab in the results section of the form.With the option_content() method you can add your HTML for your option, which you can save in the save() method of the class. 

The Torro Form results API gives you the method parse_results_for_export(), wich allows you to deal with the result data. 

This page contains the technical documentation for the Torro Forms Elements API and is written for developers. If you're not a developer you may want to review the Form Settings.

Default Usage

class My_Results extends Torro_Form_Result {
    /**
     * Sets up the contol name etc
     */
    protected function init() {
    	$this->option_name = $this->title = __( 'My Form Results' );
    	$this->name = 'my_form_results';
    }
    
    /**
     * Option content
     *
     * @param int $form_id
     *
     * @return string $html
     */
    public function option_content( $form_id ) {
        // HTML content 
    }
	
    /**
     * Saving data
     *
     * @param int $form_id
     */
    public function save( $form_id ) {
    	// Save your options
    }
}

Registering the results

    torro()->resulthandlers()->register( 'My_Results' );

Example

class My_Results extends Torro_Form_Result {
    /**
     * Sets up the contol name etc
     */
    protected function init() {
    	$this->option_name = $this->title = __( 'My Form Results', 'torro-forms' );
    	$this->name = 'my_form_results';
    }
    
    /**
     * Option content
     *
     * @param int $form_id
     *
     * @return string $html
     */
    public function option_content( $form_id ) {
        // HTML content for results tab in formbuilder
        $html  = _( 'Results by print_r function' );
        $html .= '<pre>' . print_r( $this->parse_results_for_export( $form_id, 0, 10 ) . '</pre>
    
        return $html;
    }
}

How to add your code

To add your code, we have created your the function torro_load(). Put in your function to the parameters and it will be loaded in the right way.

function your_torro_functionality(){
    require_once 'my-element-type.php';

// Also take care of the other functionality here,
// like registering the template location. } function my_plugin() { if ( ! function_exists( 'torro_load' ) ) { return; // Torro Forms is not active } torro_load( 'your_torro_functionality' ); } add_action( 'plugins_loaded', 'my_plugin' );
Fork me on GitHub