<?php error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1); session_name('nibble'); ini_set('session.gc_maxlifetime', 30 * 60); session_set_cookie_params(30 * 60); session_start(); include dirname(__FILE__) . '/nibble-flash-messaging/Flash.class.php'; $flash = Flash::getInstance(); $flash->message('Simple message example'); $flash->flashMessage('Message content goes here, 5s lifetime', 'Message title goes here', 5000); $flash->message('Sticky error message', 'Sticky message', 0, true, 'error'); include dirname(__FILE__) . '/nibble-forms/NibbleForm.class.php'; $form = NibbleForm::getInstance('', 'Submit this form', 'post', true, 'flash'); $form->username = new Text('Please enter your username', true, 20, '/[a-zA-Z0-9]+/'); $form->email = new Email('Please enter your email', false); $form->email->addConfirmation('Please confirm your email'); $form->captcha = new Captcha(); /*$form->password = new Password('Please enter your password', 11, true, true, 12); $form->password->addConfirmation('Please confirm your password'); $form->checkbox = new Checkbox('Please select one of the following', array( 'One' => 'Choice one, dont choose', 'car' => 'Choice two', 'Choice three', 'Choice four' ),true,2); $form->select = new MultipleSelect('Please select at least two of the following', array( 'One'=>'Choice one', 'Choice two', 'Choice three'
public function addConfirmation($label, $open_field = false, $close_field = false, $open_html = false, $close_html = false) { $form = NibbleForm::getInstance(); if ($form->checkField('confirm_password')) { $i = 2; while ($form->checkField('confirm_password_' . $i)) { $i++; } $form->{'confirm_password_' . $i} = new Password($label, $this->min_length, $this->alphanumeric, $this->required, $this->max_length, $this->content); $form->{'confirm_password_' . $i}->customHtml($open_field, $close_field, $open_html, $close_html); $this->confirm = 'confirm_password_' . $i; } else { $form->confirm_password = new Password($label, $this->min_length, $this->alphanumeric, $this->required, $this->max_length, $this->content); $form->confirm_password->customHtml($open_field, $close_field, $open_html, $close_html); $this->confirm = 'confirm_password'; } }
<?php $form = NibbleForm::getInstance('/admin', 'Submit me', 'post', true, 'flash', 'list'); $form->username = new Text('Please enter your username'); $form->username->errorMessage('Dont be silly buddy'); $form->email = new password('Please enter your email', 6, true, false); $form->email->addConfirmation('Please confirm your email', '', '</ul></li>'); $form->email->customHtml('<li><ul class="inline-list">', ''); $form->image = new File('Please upload an image', 'image', true, 1000000, 1600, 1600, 300, 300); $form->image->errorMessage('Duh, monkey man!'); $form->addData(array('username' => 'Luke'));