コード例 #1
0
 static function formValuesToHtml($formValues)
 {
     $div = new JFormElement('div', array('style' => 'font-family: Arial, san-serif;'));
     foreach ($formValues as $pageKey => $section) {
         $div->insert('<h1>' . Utility::stringToTitle(Utility::fromCamelCaseToSpaces($pageKey)) . '</h1>');
         foreach ($section as $sectionKey => $sectionValue) {
             // If the sectionValue is an array (instances)
             if (is_array($sectionValue)) {
                 $div->insert('<h2>' . Utility::stringToTitle(Utility::fromCamelCaseToSpaces($sectionKey)) . ' (' . sizeof($sectionValue) . ' total)</h2>');
                 foreach ($sectionValue as $sectionInstanceIndex => $section) {
                     $div->insert('<h2>(' . ($sectionInstanceIndex + 1) . ') ' . Utility::stringToTitle(Utility::fromCamelCaseToSpaces($sectionKey)) . '</h2>');
                     $div->insert(JFormer::sectionFormValuesToHtml($section));
                 }
             } else {
                 $div->insert('<h2>' . Utility::stringToTitle(Utility::fromCamelCaseToSpaces($sectionKey)) . '</h2>');
                 $div->insert(JFormer::sectionFormValuesToHtml($sectionValue));
             }
         }
     }
     return $div;
 }
コード例 #2
0
ファイル: contact-form.php プロジェクト: niieani/jformer
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$contactForm = new JFormer('contactForm', array('submitButtonText' => 'Send Message', 'title' => '<h1>Contact Us</h1>'));
// Add components to the form
$contactForm->addJFormComponentArray(array(new JFormComponentName('name', 'Name:', array('validationOptions' => array('required'), 'tip' => '<p>Please enter your full name.</p>')), new JFormComponentSingleLineText('email', 'E-mail address:', array('validationOptions' => array('required', 'email'))), new JFormComponentSingleLineText('subject', 'Subject:', array('validationOptions' => array('required'))), new JFormComponentTextArea('message', 'Message:', array('validationOptions' => array('required')))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Concatenate the name
    if (!empty($formValues->name->middleInitial)) {
        $name = $formValues->name->firstName . ' ' . $formValues->name->middleInitial . ' ' . $formValues->name->lastName;
    } else {
        $name = $formValues->name->firstName . ' ' . $formValues->name->lastName;
    }
    // Prepare the variables for sending the mail
    $toAddress = '*****@*****.**';
    $fromAddress = $formValues->email;
    $fromName = $name;
    $subject = $formValues->subject . ' from ' . $fromName;
    $message = $formValues->message;
    // Use the PHP mail function
    $mail = mail($toAddress, $subject, $message, 'From: ' . $fromAddress . "\r\n" . 'Reply-To: ' . $fromAddress . "\r\n" . 'X-Mailer: PHP/' . phpversion());
コード例 #3
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$fileComponentForm = new JFormer('fileComponentForm', array('title' => '<h1>File Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$fileComponentForm->addJFormComponentArray(array(new JFormComponentFile('file1', 'File:', array('tip' => '<p>This is a tip on a file component.</p>'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$fileComponentForm->processRequest();
コード例 #4
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$creditCardComponentForm = new JFormer('creditCardComponentForm', array('title' => '<h1>Credit Card Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$creditCardComponentForm->addJFormComponentArray(array(new JFormComponentCreditCard('creditCard1', 'Credit card:', array('tip' => '<p>This is a tip on a credit card component.</p>'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$creditCardComponentForm->processRequest();
コード例 #5
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$singleLineTextComponentForm = new JFormer('singleLineTextComponentForm', array('title' => '<h1>Single Line Text Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$singleLineTextComponentForm->addJFormComponentArray(array(new JFormComponentSingleLineText('singleLineText1', 'Single line text:', array('tip' => '<p>This is a tip on a single line text component.</p>'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$singleLineTextComponentForm->processRequest();
コード例 #6
0
ファイル: login-form.php プロジェクト: niieani/jformer
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$loginForm = new JFormer('loginForm', array('title' => '<h1>Login</h1>', 'submitButtonText' => 'Login', 'requiredText' => ' (required)'));
// Add components to the section
$loginForm->addJFormComponentArray(array(new JFormComponentSingleLineText('username', 'Username:'******'validationOptions' => array('required', 'username'), 'tip' => '<p>The <a href="/">demo</a> login is <b>admin</b>.</p>', 'persistentTip' => true)), new JFormComponentSingleLineText('password', 'Password:'******'type' => 'password', 'validationOptions' => array('required', 'password'), 'tip' => '<p>Password is 12345</p>')), new JFormComponentMultipleChoice('rememberMe', '', array(array('label' => 'Remember me')), array('tip' => '<p>If a cookie is set you can have this checked by default.</p>'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Server side checks go here
    if ($formValues->username == 'admin' && $formValues->password == '12345') {
        // If they want to be remembered
        if (!empty($formValues->rememberMe)) {
            // Let them know they successfully logged in
            $response = array('successPageHtml' => '
                <h2>Login Successful</h2>
                <p>We will keep you logged in on this computer.</p>
            ');
            // Alternatively, you could also do a redirect
            //return array('redirect' => 'http://www.jformer.com');
        } else {
            $response = array('successPageHtml' => '
                <h2>Login Successful</h2>
コード例 #7
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$textAreaComponentForm = new JFormer('textAreaComponentForm', array('title' => '<h1>Text Area Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$textAreaComponentForm->addJFormComponentArray(array(new JFormComponentTextArea('textArea1', 'Text area:', array('tip' => '<p>This is a tip on a text area component.</p>'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$textAreaComponentForm->processRequest();
コード例 #8
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$hiddenComponentForm = new JFormer('hiddenComponentForm', array('title' => '<h1>Hidden Component</h1>', 'description' => '<p>There is a hidden component in here.</p>', 'submitButtonText' => 'Test'));
// Add components to the form
$hiddenComponentForm->addJFormComponentArray(array(new JFormComponentHidden('hidden1', 'Hey there!')));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$hiddenComponentForm->processRequest();
コード例 #9
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$htmlComponentForm = new JFormer('htmlComponentForm', array('title' => '<h1>HTML Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$htmlComponentForm->addJFormComponentArray(array(new JFormComponentHtml('<p>This is an HTML component. It records no input and has no validation. Use it to insert HTML inbetween your components.</p>')));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$htmlComponentForm->processRequest();
コード例 #10
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$multipleChoiceComponentForm = new JFormer('multipleChoiceComponentForm', array('title' => '<h1>Multiple Choice Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$multipleChoiceComponentForm->addJFormComponentArray(array(new JFormComponentMultipleChoice('multipleChoice1', 'Multiple choice checkboxes:', array(array('label' => 'Option 1', 'value' => '1'), array('label' => 'Option 2', 'value' => '2', 'checked' => true), array('label' => 'Option 3', 'value' => '2')), array('tip' => '<p>This is a tip on a multiple choice component.</p>')), new JFormComponentMultipleChoice('multipleChoice2', 'Multiple choice radio buttons:', array(array('label' => 'Option 1', 'value' => '1'), array('label' => 'Option 2', 'value' => '2', 'checked' => true), array('label' => 'Option 3', 'value' => '2')), array('multipleChoiceType' => 'radio'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$multipleChoiceComponentForm->processRequest();
コード例 #11
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$dateComponentForm = new JFormer('dateComponentForm', array('title' => '<h1>Date Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$dateComponentForm->addJFormComponentArray(array(new JFormComponentDate('date1', 'Date:', array('tip' => '<p>This is a tip on a date component.</p>'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$dateComponentForm->processRequest();
コード例 #12
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$likertComponentForm = new JFormer('likertComponentForm', array('title' => '<h1>Likert Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$likertComponentForm->addJFormComponentArray(array(new JFormComponentLikert('likert1', 'Likert component:', array(array('value' => '1', 'label' => 'Yes', 'sublabel' => 'Yes'), array('value' => '2', 'label' => 'No', 'sublabel' => 'No')), array(array('name' => 'statement1', 'statement' => 'Statement 1', 'validationOptions' => array('required')), array('name' => 'statement2', 'statement' => 'Statement 2'), array('name' => 'statement3', 'statement' => 'Statement 3', 'description' => '<p>Statement description.</p>', 'tip' => '<p>This is a tip on a statement.</p>')), array('validationOptions' => array('required'), 'description' => '<p>Likert description.</p>'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$likertComponentForm->processRequest();
コード例 #13
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$addressComponentForm = new JFormer('addressComponentForm', array('title' => '<h1>Address Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$addressComponentForm->addJFormComponentArray(array(new JFormComponentAddress('address1', 'Standard address:', array('tip' => '<p>This is a tip on an address component.</p>')), new JFormComponentAddress('address2', 'Address without second line:', array('addressLine2Hidden' => true)), new JFormComponentAddress('address3', 'Address for United States only:', array('unitedStatesOnly' => true)), new JFormComponentAddress('address3', 'Address for United States only:', array('unitedStatesOnly' => true)), new JFormComponentAddress('address4', 'Address with a selected country:', array('selectedCountry' => 'US'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$addressComponentForm->processRequest();
コード例 #14
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$dropDownComponentForm = new JFormer('dropDownComponentForm', array('title' => '<h1>Drop Down Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$dropDownComponentForm->addJFormComponentArray(array(new JFormComponentDropDown('dropDown1', 'Drop down:', array(array('label' => 'Choice 1', 'value' => '1'), array('label' => 'Choice 2', 'value' => '2'), array('label' => 'Choice 3', 'value' => '3'), array('label' => 'Choice 4', 'value' => '4'), array('label' => 'Choice 5', 'value' => '5')), array('tip' => '<p>This is a tip on a drop down component.</p>'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$dropDownComponentForm->processRequest();
コード例 #15
0
<?php

// Include the jFormer PHP (use an good path in your code)
if (file_exists('../php/JFormer.php')) {
    require_once '../php/JFormer.php';
} else {
    if (file_exists('../../php/JFormer.php')) {
        require_once '../../php/JFormer.php';
    }
}
// Create the form
$nameComponentForm = new JFormer('nameComponentForm', array('title' => '<h1>Name Component</h1>', 'submitButtonText' => 'Test'));
// Add components to the form
$nameComponentForm->addJFormComponentArray(array(new JFormComponentName('name1', 'Name:', array('tip' => '<p>This is a tip on a name component.</p>'))));
// Set the function for a successful form submission
function onSubmit($formValues)
{
    // Return a simple debug response
    return array('failureNoticeHtml' => json_encode($formValues));
}
// Process any request to the form
$nameComponentForm->processRequest();