0

PM bmx322

Hi All,

I am integrating JFormer with CI. I am able to get the form to build but the validation doesn’t work and there are no POST vars nor any values in the jformer formValues on submission.

I load the JS files in a header template and have CI config’d to auto-load the jformer.php library.

Has anyone been able to get JFormer working in CI 2.1.2?

I’d greatly appreciate any help!

Thanks!

http://www.jformer.com/

2
Contributors
9
Replies
40
Views
4 Years
Discussion Span
Last Post by shakayu
0

Am trying to integrate jFormer in codeigniter...but i dont know how :S...

Have you check the jFormer?

0
require_once($_SERVER['DOCUMENT_ROOT'] . '/php/site.php');
002  
003 // Create the form
004 $registration = new JFormer('registration', array(
005             'submitButtonText' => 'Register',
006         ));
007  
008 // Create the form page
009 $jFormPage1 = new JFormPage($registration->id . 'Page', array(
010             'title' => '<p>Registration Demo</p>',
011             'description' => '<p>None of your data from this form is acutally stored, so feel free to put whatever.</p>',
012         ));
013  
014 // Create the form section
015 $jFormSection1 = new JFormSection($registration->id . 'Section1', array(
016         ));
017  
018 // Create the form section
019 $jFormSection2 = new JFormSection($registration->id . 'Section2', array(
020         ));
021  
022 // Add components to the section
023 $jFormSection1->addJFormComponentArray(array(
024     new JFormComponentSingleLineText('username', 'Username:', array(
025         'validationOptions' => array('required', 'username'),
026     )),
027     new JFormComponentSingleLineText('email', 'E-mail Address:', array(
028         'validationOptions' => array('required', 'email'),
029     )),
030     new JFormComponentSingleLineText('password', 'Password:', array(
031         'type' => 'password',
032         'validationOptions' => array('required', 'password'),
033     )),
034     new JFormComponentSingleLineText('passwordConfirm', 'Confirm Password:', array(
035         'type' => 'password',
036         'validationOptions' => array('required', 'password', 'matches' => 'password'),
037     )),
038     new JFormComponentMultipleChoice('updates', '', array(
039         array('value' => 'signup', 'label' => 'I would like to recieve updates.'),
040             ),
041             array()),
042     new JFormComponentMultipleChoice('update_type', 'How would you like to recieve updates?', array(
043         array('value' => 'Email', 'label' => 'Send updates to my Email'),
044         array('value' => 'Text Message', 'label' => 'Send updates to my Phone via Text Message'),
045             ),
046             array(
047                 'multipleChoiceType' => 'radio',
048                 'validationOptions' => array('required'),
049                 'dependencyOptions' => array(
050                     'dependentOn' => 'updates',
051                     'display' => 'hide',
052                     'jsFunction' => '$("#updates-choice1").is(":checked");'
053                 ),
054     )),
055     new JFormComponentSingleLineText('phone', 'Phone Number:', array(
056         'mask' => '(999) 999-9999',
057         'validationOptions' => array('required'),
058         'dependencyOptions' => array(
059             'dependentOn' => array('update_type', 'updates'),
060             'display' => 'hide',
061             'jsFunction' => '$("#update_type-choice2").is(":checked") && $("#updates-choice1").is(":checked");'
062         ),
063     )),
064     new JFormComponentMultipleChoice('terms', '', array(
065         array('value' => 'agree', 'label' => 'Do you agree to the site <a href="/legal/terms-and-conditions/" target="_blank">Terms and Conditions</a>?'),
066             ),
067             array(
068                 'validationOptions' => array('required'),
069     )),
070 ));
071  
072 // Add the section to the page
073 $jFormPage1->addJFormSection($jFormSection1);
074  
075 // Add the page to the form
076 $registration->addJFormPage($jFormPage1);
077  
078 // Set the function for a successful form submission
079 function onSubmit($formValues) {
080     //return array('failureHtml' => json_encode($formValues));
081     $secondary = '';
082     if ($formValues->registrationPage->registrationSection1->updates[0] == 'signup') {
083         $updates = 'yes';
084         // type, and detail
085         $type = $formValues->registrationPage->registrationSection1->update_type;
086         $secondary = '<p>Update Type: ' . $type . '</p>';
087         if ($type == 'phone') {
088             $secondary .= '<p>Phone Number: ' . $formValues->registrationPage->registrationSection1->phone . '</p>';
089         }
090     } else {
091         $updates = 'no';
092     }
093  
094  
095     return array(
096         'successPageHtml' => '<p>Thanks for Using jFormer</p>
097             <p>Username: ' . $formValues->registrationPage->registrationSection1->username . '</p>
098             <p>E-mail: ' . $formValues->registrationPage->registrationSection1->email . '</p>
099             <p>Updates</p>
100             <p>Receive Updates: ' . $updates . '</p>
101             '.$secondary,
102     );
103 }
104  
105 // Process any request to the form
106 $registration->processRequest();
0

I want the code above into Codeigniter..can anyone help me :(

0
View

<html>
<head>
<title> Registration Patient Form </title>


<link href="<?php echo base_url();?>css/krylov.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>css/form.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>css/mws-theme.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>css/button.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>css/mws-style.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>bootstrap/css/bootstrap.min.cs" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>css/fonts/ptsans/stylesheet.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>css/fonts/icomoon/style.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>css/icons/icol32.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>css/fonts/icomoon/style.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>jui/css/jquery.ui.all.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>jui/jquery-ui.custom.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url();?>css/themer.css" type="text/css" rel="stylesheet"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="<?php echo base_url();?>js/label_adjust.js" ></script>



<style type="text/css">



form li {
    list-style: none;
     }
</style>


<script> 

        $(document).ready(function() { 


            $('#main').adjustLabel({
                element : '.adjust',
                minWidth: '90px'
            });
         }); 

 </script> 


</head>

<body>

<!-- wrap starts here -->
<div id="wrap">

    <!--header -->
    <div id="header">           

        <div id="header-links"></div>       

    <!--header ends-->                  
    </div>
    <div id="header-photo">
     </div>      

    <!-- navigation starts-->   
    <div  id="nav">
        <ul>
            <li id="current"><a href="index.html">Home</a></li>
            <li><a href="index.html">About Us</a></li>
            <li><a href="index.html">Services</a></li>
            <li><a href="index.html">Support</a></li>
            <li><a href="index.html">Contact Us</a></li>        
        </ul>
    <!-- navigation ends--> 
    </div>                  

    <!-- content-wrap starts -->
    <div id="content-wrap" class="three-col"  > 

        <div id="sidebar">

            <h1>Search Box</h1> 
            <form action="#" class="searchform">
                <p>
                <input name="search_query" class="textbox" type="text" />
                <input name="search" class="button" value="Search" type="submit" />
                </p>            
            </form> 

            <h1>Sidebar Menu</h1>
            <ul class="sidemenu">               
                <li><a href="#">Register</a></li>
                <li><a href="#">Appointments</a></li>
                <li><a href="#">My Account</a></li>

            </ul>   



        <!-- sidebar ends -->       
        </div>



        <?php



echo  form_open($base_url . 'index.php/patient');



$First_Name=array(
    'name'      =>  'First_Name',
    'id'        =>  'First_Name',

);


$Last_Name=array(
    'name'      =>  'Last_Name',
    'id'        =>  'Last_Name',

);


$male=array(
    "name"      =>  'Gender',
     "id"       =>  'male',
    "value"     =>  'Male',
    "checked"   => set_radio('Gender', 'Male' , TRUE)


);


$female=array(
    "name"      =>  'Gender',
    "id"        =>  'female',
    "value"     =>  'Female',
    "checked"   => set_radio('Gender', 'Female')



);


$Date_of_Birth=array(
    'name'      =>  'Date_of_Birth',
    'id'        =>  'Date_of_Birth',
    'type'      =>   'date'


);  



$Street=array(
    'name'      =>  'Street',
    'id'        =>  'Street',

);


$Town=array(
    'name'      =>  'Town',
    'id'        =>  'Town',

);

$Home=array(
    'name'      =>  'Home',
    'id'        =>  'Home',

);

$Mobile=array(
    'name'      =>  'Mobile',
    'id'        =>  'Mobile',

);


$Office=array(
    'name'      =>  'Office',
    'id'        =>  'Office',

);

$Email_Address=array(
    'name'      =>  'Email_Address',
    'id'        =>  'Email_Address',

);

$Weight=array(
    'name'      =>  'Weight',
    'id'        =>  'Weight',

);

$Blood_Pressure=array(
    'name'      =>  'Blood_Pressure',
    'id'        =>  'Blood_Pressure',

);


?>



         <div id="main">


                   <div class="mws-panel grid_8">

                        <div class="mws-panel-header">
                            <span><i class="icon-magic"></i>Patient Registration Form</span>
                        </div>


                        <div class="mws-panel-body no-padding">

                        <fieldset class="wizard-step mws-form-inline">

        <ul>                     


        <li>
         <div>
            <label class="adjust">First Name</label>
            <?php echo form_input($First_Name); ?>
        </div>
        </li>



        <li>
         <div>
            <label class="adjust":>Last Name</label>
            <?php echo form_input($Last_Name); ?>
        </div>
        </li>


        <li>
           <div>
             <label class="adjust">Date Of Birth</label>
            <?php echo form_input($Date_of_Birth); ?>
           <i class="icol32-calendar-view-week" ></i>
        </div>
        </li>




        <li>
        <div>
            <label class="adjust">Gender</label>
            <?php echo form_radio($male); ?>
            <?php echo form_label('Male'); ?>
            <?php echo form_radio($female); ?>
            <?php echo form_label('Female'); ?>
        </div>
        </li>


        <li>
        <div>
           <label class="adjust">Street</label>
            <?php echo form_input($Street); ?>
        </div>
        </li>


        <li>
        <div>
            <label class="adjust">Town</label>
            <?php echo form_input($Town); ?>
        </div>
        </li>

        <li>

        <div>
           <label class="adjust">Home</label>
            <?php echo form_input($Home); ?>
            <i class="icol32-telephone" ></i>
        </div>
        </li>


        <li>

        <div>
            <label class="adjust">Mobile</label>
            <?php echo form_input($Mobile); ?>
            <i class="icol32-blackberry-white" ></i>
        </div>
        </li>

        <li>

        <div>
            <label class="adjust">Office</label>
            <?php echo form_input($Office); ?>

            <i class="icol32-telephone" ></i>
        </div>
        </li>



        <li>

        <div>
            <label class="adjust">Email Address</label>
            <?php echo form_input($Email_Address); ?>
        </div>
        </li>



        <li>

        <div>
            <label class="adjust">Weight</label>
            <?php echo form_input($Weight); ?>
        </div>
        </li>




        <li>

        <div>
            <label class="adjust">Blood Pressure</label>
            <?php echo form_input($Blood_Pressure); ?>
        </div>
        </li>




        <div>
            <?php echo form_submit(array('name' => 'register'), 'Register');  ?>
        </div>
        </li>


</div>

      <?php echo form_close(); ?>

</ul>

</fieldset>


                    </div>
                </div>

                    </div>

<!-- footer starts -->          
    <div id="footer-wrap"><div id="footer">             

            <p>
            &copy; 2013 Krylov Orthopaedic & Rehabilitation Centre

            &nbsp;&nbsp;&nbsp;&nbsp;

            <a>Design</a> by <a>Karishma</a> 

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


            </p>

    </div></div>
    <!-- footer ends--> 

<!-- wrap ends here -->
</div>






</body>
</html>




Now i want to integrate JfoRmer For the validation purpose :s
0

You can include it in the Controller construct:

class Test extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        include($this->input->server('DOCUMENT_ROOT').'/application/third_party/jformer.php');
    }

But I'm not sure if it will work properly.

Edited by cereal

0

You can include external libraries by using $this->load->library() or by placing an __autoload() inside /application/config/config.php.

But in order to work:

  • jformer.php classes needs to be splitted one class per file;
  • you need to include the abstract class JFormComponent apart;
  • and you have to save the files into /application/libraries/ if using the loader library, or /application/third_party/ for include, require and __autoload().

However, this is not an easy result to achieve, at least for me, without a modify of jformer.php. If you are trying to use it only for validation purpouses, why don't you use the internal validation library?

Anyway, I'm sorry I cannot help much more on this.

0

The Validation library extend the content of the form..that the main problem :(
anyways than you :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.