Rabbit Form Modification

I like Rabbit Forms for it’s simplicity and extendability.Today I am going to show you a modified RabbitForm library to achieve the following effect. This is actually taken from one of my project … but little modified. Let’s says: I have a quiz with options. Each quiz will have multiple Options 1:N relation. As you may know Rabbit Forms has a DropDown list that can be used to achieve such operation. But I wanted little easier one, i dont’ wanted to click and select the parent table relation everytime. A little more flexible and effective solution. Check the following Steps To see my modified form. By the by, I did not used a custom form view. The default options and some tweaking with the Rabbitform library did all the trick.

Step1:
 Code: $this->rabbitform->retrieve(‘quiz.yml’); 



Step 2:
code:
function quiz_manage( $quiz_id ) {
    $html = $this->rabbitform->run(‘quiz.yml’, $quiz_id);
    $html .= ‘<br />’;
    $html .= $this->rabbitform->retrieve(‘option.yml’, 0,
                array( “tbl_quiz_id = $quiz_id”),
                array(
                    ‘manage’ => “quiz/option_manage/$quiz_id/”                
                )
            );
    $this->masterpage( $html );
}
Note:
   the retrieve function now can accept 2 more extra parameters. 3 rd parameter represents the new filter which only shows the options of that particular quiz. And 4th parameter defines the location of option’s manage path.
 

Step 3:

code :
function  option_manage( $quiz_id, $option_id = false )
{
      $rundata = $this->rabbitform->run(‘option.yml’, $option_id,
                array(‘tbl_quiz_id’ => $quiz_id),
                array(
                    ‘manage’ => “quiz/option_manage/$quiz_id/”                
                )                
        );
      if( $rundata )  $this->masterpage( $rundata );
      else  $this->quiz_manage( $quiz_id );
}

 

Note:
Here  ‘run’ method accepts 3rd  parameter which defines the hidden values.



Get the Rabbitform.php from download section and overrite with the original one in application/library folder. Rabbit Forms version is If any bug or problem occurs let me. Till now i haven’t found any problem.

Advertisements

2 thoughts on “Rabbit Form Modification

  1. Tommy says:

    Do you have another rabbit-forms modification?
    i also use rabbit-form and search another improvement for that library..

  2. tohin says:

    I haven’t used rabbit-forms for a while so did not done any modification .. but u can check the codeigniter thread for updates or improvements.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s