Exemplo n.º 1
0
 protected function setupForm(Form $form)
 {
     $form->addText('name', 'Name')->setRequired();
     $form->addTextArea('content', 'Content')->setAttribute('class', 'editor-standard');
     $form->addCheckbox('active', 'Active');
     $form->addSubmit('submit', 'Submit');
 }
 public function createComponentArticleForm()
 {
     $form = new Nette\Forms\Form();
     $form->addText('title', 'Název')->setRequired('Název je povinný')->addRule(Form::MAX_LENGTH, 'Délka je maximálně 60 znaků', 60);
     $form->addTextArea('content', 'Obsah')->setRequired();
     $form->addButton('send', 'Přidat');
     $form->onSuccess[] = array($form, function ($form) {
         $values = $form->getValues();
         //doSomething($values->title);
     });
     return $form;
 }
Exemplo n.º 3
0
 protected function setupForm(Form $form)
 {
     $form->addText('name', 'Name')->setRequired();
     $form->addTextArea('description', 'Description')->setAttribute('class', 'editor-standard');
     $form->addText('price', 'Price')->setType('number')->setRequired();
     $form->addUpload('image', 'Image')->addCondition(Form::FILLED)->addRule(Form::IMAGE);
     $form->addText('unit', 'Unit')->setRequired();
     $form->addText('vat', 'Vat Rate')->setType('number')->setRequired();
     $form->addCheckbox('active', 'Active');
     $form->addSubmit('submit', 'Submit');
     $this->onPreSave[] = $this->saveImage;
 }
Exemplo n.º 4
0
// 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;
        }
    }
Exemplo n.º 5
0
 /**
  * Email subscribers
  *
  * @return \Nette\Forms\Form
  */
 public static function email(array $get)
 {
     $form = new Form('adminEmail');
     // Prepare
     if (isset($get['action']) && $get['action'] == 'email') {
         $preFill = TRUE;
     } else {
         $preFill = FALSE;
     }
     $emailWhoDefault = $preFill ? 2 : 1;
     $emailSubscriberDefault = isset($get['email']) ? $get['email'] : '';
     // Email subscribers
     $form->addGroup('E-mail Subscriber(s)');
     $form->addSelect('emailWho', 'Recipient(s)', array(1 => 'All subscriber(s)', 2 => 'Single Subscriber', 3 => 'Wordpress Registered subscribers', 4 => 'Non-wordpress Registered subscribers'))->setDefaultValue($emailWhoDefault)->addCondition(Form::EQUAL, 2)->toggle("subscriber");
     $form->addGroup()->setOption('container', Html::el('fieldset')->id("subscriber"));
     $form->addText("email", "Subscriber")->setDefaultValue($emailSubscriberDefault)->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Must be valid e-mail address');
     $form->addGroup();
     $form->addText('subject', 'Subject')->setRequired('Subject is required');
     $form->addTextArea('body', 'E-mail message')->setRequired('You don\'t want to send an empty message now do you :)');
     // Submit
     $form->addSubmit('submit', 'Send')->setAttribute('class', 'button-primary');
     return $form;
 }
Exemplo n.º 6
0
$form = new Form;
$form->addText('name');
$form->addText('age');
$form->addRadioList('gender', NULL, $sex);
$form->addText('email')->setEmptyValue('@');

$form->addCheckbox('send');
$form->addText('street');
$form->addText('city');
$form->addSelect('country', NULL, $countries)->setPrompt('Select your country');

$form->addPassword('password');
$form->addPassword('password2');
$form->addUpload('avatar');
$form->addHidden('userid');
$form->addTextArea('note');

$form->addSubmit('submit');


// Step 1b: Define validation rules
$form['name']->setRequired('Enter your name');

$form['age']->setRequired('Enter your age');
$form['age']->addRule($form::INTEGER, 'Age must be numeric value');
$form['age']->addRule($form::RANGE, 'Age must be in range from %d to %d', array(10, 100));

// conditional rule: if is email filled, ...
$form['email']->addCondition($form::FILLED)
	->addRule($form::EMAIL, 'Incorrect email address'); // ... then check email
Exemplo n.º 7
0
		<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');
$form->addText('dbport', 'port:')->setOption('description', 'Zadejte port mysql serveru obykle 3306')->addRule(Form::INTEGER, 'Port musí být číslo')->setType('number');
$form->addText('dbuser', 'user:'******'description', 'Zadejte uživatelské jméno');
$form->addText('dbpassword', 'heslo:')->setOption('description', 'Zadejte heslo');
$form->addText('dbname', 'Název databáze:')->setOption('description', 'Zadejte název databáze');
$form->addText('dbtablename', 'Název tabulky:')->setOption('description', 'Zadejte název tabulky');
Exemplo n.º 8
0
<div class="page-header">
  <h1>
    <i class="fa fa-plus"></i> Add a new station log
  </h1>
</div>
<?php 
use Nette\Forms\Form;
use Kdyby\BootstrapFormRenderer\BootstrapRenderer;
$form = new Form();
$form->setRenderer(new BootstrapRenderer());
$form->addProtection();
$form->addText('reporter', 'Nickname')->setAttribute('placeholder', 'anonymous')->setRequired();
date_default_timezone_set("UTC");
$form->addText('datetime', 'When')->setAttribute('placeholder', '2014-01-01 14:00')->setDefaultValue(date('Y-m-d H:i:s'))->setRequired();
$form->addText('station', 'Station designator')->setRequired()->setAttribute('placeholder', 'E11');
$form->addText('qrh', 'Frequency')->setRequired()->setAttribute('placeholder', '4625')->addRule(Form::FLOAT);
$form->addText('callnumber', 'Call # (leave empty if not captured)')->setAttribute('placeholder', '472 639 5 or 441/30');
$form->addText('callid', 'Call ID (leave empty if not captured)')->setAttribute('placeholder', '472 639 5 or 441/30');
$form->addText('gc', 'Group Count')->setAttribute('placeholder', '10');
$form->addTextArea('body', 'Message (leave empty if not captured)')->setAttribute('placeholder', '39715 12345');
$form->addSubmit('send', 'Add to our mighty database');
if ($form->isSuccess() && $form->isValid()) {
    //die();
    $f = $form->getValues();
    //dump($f);
    $arr = array('time' => $f['datetime'], 'station' => $f['station'], 'qrh' => $f['qrh'], 'call_number' => $f['callnumber'], 'call_id' => $f['callid'], 'gc' => $f['gc'], 'body' => $f['body'], 'reporter' => $f['reporter']);
    dibi::query('insert into logs_new', $arr);
    echo "Log has been added. Thank you.";
}
$form->render();