Example #1
0
// ... then check email
// group Shipping address
$form->addGroup('Shipping address')->setOption('embedNext', TRUE);
$form->addCheckbox('send', 'Ship to address')->addCondition(Form::EQUAL, TRUE)->toggle('sendBox');
// toggle div #sendBox
// subgroup
$form->addGroup()->setOption('container', Html::el('div')->id('sendBox'));
$form->addText('street', 'Street');
$form->addText('city', 'City')->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Enter your shipping address');
$form->addSelect('country', 'Country', $countries)->skipFirst()->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Select your country');
// group Your account
$form->addGroup('Your account');
$form->addPassword('password', 'Choose password')->addRule(Form::FILLED, 'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3)->setOption('description', '(at least 3 characters)');
$form->addPassword('password2', 'Reenter password')->addConditionOn($form['password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']);
$form->addFile('avatar', 'Picture');
$form->addHidden('userid');
$form->addTextArea('note', 'Comment');
// group for buttons
$form->addGroup();
$form->addSubmit('submit', 'Send');
// Step 2: Check if form was submitted?
if ($form->isSubmitted()) {
    // Step 2c: Check if form is valid
    if ($form->isValid()) {
        echo '<h2>Form was submitted and successfully validated</h2>';
        $values = $form->getValues();
        Debug::dump($values);
        // this is the end, my friend :-)
        if (empty($disableExit)) {
            exit;
        }
Example #2
0
 /**
  * Add subscriber, from admin
  *
  * @param array $fields
  * @return Nette\Forms\Form
  */
 public static function subscribeAdmin($fields = array())
 {
     $form = new Form('addSubscriberAdmin');
     // Subscriber
     $form->addText('email', 'E-mail')->setRequired('E-mail address is requried.')->addRule(Form::EMAIL, 'Must be valid e-mail address');
     $form->addCheckbox('active', 'Active')->setDefaultValue(1);
     if (array_key_exists('firstName', $fields)) {
         $form->addText('firstName', 'First Name');
     }
     if (array_key_exists('lastName', $fields)) {
         $form->addText('lastName', 'Last Name');
     }
     if (array_key_exists('age', $fields)) {
         $form->addText('age', 'Age')->addCondition(Form::FILLED)->addRule(Form::INTEGER, 'Age must be a numeric number.')->addRule(Form::RANGE, 'Age should be between 8 and 120 years :).', array(5, 120));
     }
     if (array_key_exists('interests', $fields)) {
         $form->addTextarea('interests', 'Interests');
     }
     if (array_key_exists('location', $fields)) {
         $form->addText('location', 'Location');
     }
     $form->addHidden('date', date('Y-m-d H:i:s'));
     $form->addText('ip', 'Ip')->setDefaultValue(Utils::getRealIp())->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Must be valid IP', '((^|\\.)((25[0-5])|(2[0-4]\\d)|(1\\d\\d)|([1-9]?\\d))){4}$');
     // Submit
     $form->addSubmit('submit', 'Add')->setAttribute('class', 'button-primary');
     return $form;
 }
Example #3
0
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width">
		<link rel="stylesheet" href="css/bootstrap.css">
		<link rel="stylesheet" href="css/b7.css">
		<script src="js/jquery.js"></script>
		<script src="js/netteForms.js"></script>
		<script src="js/main.js"></script>
	</head>
	<body>
		
		<div style="width: 800px;">
			
		<?php 
echo "<h2>" . date('d.m.Y H:i:s') . "</h2>";
$form = new Form();
$form->addHidden('general', '[GENERAL]');
$form->addHidden('file');
$form->addGroup('B7 setting');
$form->addHidden('b7', '[B7]');
$form->addText('stanoviste', 'Číslo stanoviště:')->setOption('description', 'Zadejte číslo stanoviště od 1 do 999')->setRequired('Zadejte číslo od 1 do 999')->addRule(Form::INTEGER, 'Stanoviště musí být číslo')->addRule(Form::RANGE, 'Číslo musí být od 1 do 99', array(1, 999))->setType('number');
$form->addHidden('cards');
$form->addHidden('ftp', '[FTP]');
$form->addHidden('server');
$form->addHidden('user');
$form->addHidden('password');
$form->addHidden('dstdir');
$form->addHidden('db', '[DB]');
$form->addHidden('script');
$form->addHidden('dbserver');
$form->addHidden('dbport');
$form->addHidden('dbuser');
Example #4
0
<?php

/**
 * Nette\Forms Cross-Site Request Forgery (CSRF) protection example.
 */
require_once __DIR__ . '/../../Nette/loader.php';
use Nette\Forms\Form, Nette\Debug;
Debug::enable();
$form = new Form();
$form->addProtection('Security token did not match. Possible CSRF attack.', 3);
$form->addHidden('id')->setDefaultValue(123);
$form->addSubmit('submit', 'Delete item');
// Step 2: Check if form was submitted?
if ($form->isSubmitted()) {
    // Step 2c: Check if form is valid
    if ($form->isValid()) {
        echo '<h2>Form was submitted and successfully validated</h2>';
        $values = $form->getValues();
        Debug::dump($values);
        // this is the end, my friend :-)
        if (empty($disableExit)) {
            exit;
        }
    }
}
// Step 3: Render form
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
Example #5
0
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width">
		<link rel="stylesheet" href="css/bootstrap.css">
		<link rel="stylesheet" href="css/b7.css">
		<script src="js/jquery.js"></script>
		<script src="js/netteForms.js"></script>
		<script src="js/main.js"></script>
	</head>
	<body>
		
		<div style="width: 900px;">
		<?php 
echo "<h2>" . date('d.m.Y H:i:s') . "</h2>";
$form = new Form();
$form->addGroup('GENERAL setting');
$form->addHidden('general', '[GENERAL]');
$form->addText('file', 'soubor:')->setOption('description', Html::el('b')->setHtml('/home/pi/b7/vysledky.log Cesta pro umisteni souboru !!'))->setRequired('Zadejte název souboru');
$form->addGroup('B7 setting');
$form->addHidden('b7', '[B7]');
$form->addText('stanoviste', 'Číslo stanoviště:')->setOption('description', 'Zadejte číslo stanoviště od 1 do 999')->setRequired('Zadejte číslo od 1 do 999')->addRule(Form::INTEGER, 'Stanoviště musí být číslo')->addRule(Form::RANGE, 'Číslo musí být od 1 do 99', array(1, 999))->setType('number');
$form->addTextArea('cards', 'Service cards:')->setOption('description', 'Zadejte čísla karet v hexadecimalnim formatu oddělené "|"')->setRequired('Zadejte číslo karty ve formátu hexa|hexa')->addRule(Form::PATTERN, 'cards neplatný formát hexa|hexa', '^(([a-fA-F0-9]){8})(\\|(([a-fA-F0-9]){8}))*$');
$form->addGroup('FTP setting');
$form->addHidden('ftp', '[FTP]');
$form->addText('ftpserver', 'server:')->setOption('description', 'Zadejte adresu ftp serveru')->setRequired('Zadejte adresu ftp serveru');
$form->addText('ftpuser', 'user:'******'description', 'Zadejte uživatelské jméno')->setRequired('Zadejte uživatelské jméno');
$form->addText('ftppassword', 'heslo:')->setOption('description', 'Zadejte heslo')->setRequired('Zadejte heslo');
$form->addText('ftpdstdir', 'Cílový adresář:')->setOption('description', 'Zadejte název cílového adresáře kde bude uložen soubor s logy /log')->setRequired('Zadejte název cílového adresáře');
$form->addGroup('MYSQL setting');
$form->addHidden('db', '[DB]');
$form->addText('script', 'Ceata ke skriptu: ')->setOption('description', Html::el('b')->setHtml('/home/pi/b7/b7_mysql.sh Nevyplněno znamená neodesílat data přímo do databáze !!'));
$form->addText('dbserver', 'server:')->setOption('description', 'Zadejte adresu mysql serveru');
Example #6
0
use Nette\Forms\Form;
?>
<html>
	<head>
		 <title>B7 time setting</title>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width">
		<link rel="stylesheet" href="css/bootstrap.css">
		<link rel="stylesheet" href="css/b7.css">
		<script src="js/jquery.js"></script>
		<script src="js/netteForms.js"></script>
		<script src="js/main.js"></script>
	</head>
	<body>
		<?php 
$form = new Form();
$form->addGroup('GENERAL setting');
$form->addHidden('general', '[GENERAL]');
$form->addText('datetime', 'Datum a čas:')->setOption('description', 'Zadejte název souboru')->setRequired('Zadejte název souboru');
$form->addSubmit('send', 'Uložit');
$form->setDefaults($ini_array);
echo $form;
// vykreslí formulář
if ($form->isSuccess()) {
    $values = $form->getValues(true);
    echo "\t<script>\r\n\t\t\t\t\t\t\talert('Formulář byl uložen');\r\n\t\t\t\t\t\t\twindow.location.replace('time.php');\r\n\t\t\t\t\t\t</script>)";
}
?>
		
	</body>
</html>