mardi 24 février 2015

Can't generate errors when using PFBC validation

Problem:


I have adopted the framework of PFBC in order to validate form elements but despite following (at least what I believe) every step to validate a form field it does not generate the error message.


Code:



<?php
// Initialize session
session_start();

use PFBC\Form;
use PFBC\Element;
use PFBC\Validation;
use PFBC\View;

// Include PHP Form Builder Class
require_once 'inc/PFBC/Form.php';

// Include PHP PDO Wrapper Class
require_once 'inc/class.db.php';

// Define database configuration
require_once 'inc/class.config.php';

// Include header
require_once 'inc/header.php';

$form = new Form("validation");

$form->configure(array(
"prevent" => array("bootstrap", "jQuery", "focus")
));

$form->addElement(new Element\Hidden("form", "validation"));
$form->addElement(new Element\HTML('<legend>Title - <small>Subtitle</small></legend>'));
$form->addElement(new Element\HTML('<p>Text</p>'));
$form->addElement(new Element\Password("Enter code:", "Password", array(
"validation" => new Validation\AlphaNumeric,
"longDesc" => "The AlphaNumeric validation class will verify that the element's submitted value contains only letters, numbers, underscores, and/or hyphens.",
"required" => 1
)));
$form->addElement(new Element\Button("Send"));
$form->render();

// Include footer
require_once 'inc/footer.php';
?>


Desired output:


An error message should be displayed if user left field empty.


Aucun commentaire:

Enregistrer un commentaire