当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::addText方法代码示例

本文整理汇总了PHP中Nette\Forms\Form::addText方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addText方法的具体用法?PHP Form::addText怎么用?PHP Form::addText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Forms\Form的用法示例。


在下文中一共展示了Form::addText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createComponentLoginForm

 function createComponentLoginForm()
 {
     $form = new Form();
     $form->addText('login')->setAttribute('id', 'login')->setAttribute('class', 'text')->addRule(Form::FILLED, 'Zadejte jméno!');
     $form->addText('password')->setAttribute('id', 'password')->setAttribute('clas', 'text')->addRule(Form::FILLED, 'Zadejte heslo!');
     $form->addSubmit('send')->setAttribute('id', 'Přihlásit')->setAttribute('class', 'ok');
     $form->onSuccess[] = array($this, 'loginFormSucceded');
     return $form;
 }
开发者ID:B4rtosek,项目名称:sislak,代码行数:9,代码来源:LoginPresenter.php

示例2: setupForm

 protected function setupForm(Form $form)
 {
     $uniqueValidator = new UniqueValidator($this->database->table($this->table), $this->getId());
     $form->addText('name', 'Name')->setRequired();
     $form->addText('email', 'Email')->setRequired()->setType('email')->addRule(Form::EMAIL)->addRule($uniqueValidator->validate, 'This email is already registered.');
     $form->addPassword('password', 'Password')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, NULL, 6);
     $roles = array_combine($this->roles, $this->roles);
     $form->addRadioList('role', 'Role', $roles)->setRequired();
     $form->addSubmit('submit', 'Submit');
     $this->onPreSave[] = $this->hashPassword;
 }
开发者ID:04EO,项目名称:TrainingTaskNette,代码行数:11,代码来源:UserFormFactory.php

示例3: setupForm

 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;
 }
开发者ID:04EO,项目名称:TrainingTaskNette,代码行数:12,代码来源:ProductFormFactory.php

示例4: setupForm

 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');
 }
开发者ID:04EO,项目名称:TrainingTaskNette,代码行数:7,代码来源:PageFormFactory.php

示例5: createComponentArticleForm

 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;
 }
开发者ID:KennyDaren,项目名称:Nette_Lessons,代码行数:12,代码来源:HomepagePresenter.php

示例6: addFormControl

 public function addFormControl(\Nette\Forms\Form $form, Builder\Metadata $meta)
 {
     $input = $form->addText($meta->name, $meta->label);
     $input->getControlPrototype()->type('number');
     $input->addCondition(Builder\EntityForm::FILLED)->addRule($meta->type === 'float' ? Builder\EntityForm::FLOAT : Builder\EntityForm::INTEGER);
     if ($meta->type === 'float') {
         $step = isset($meta->custom['step']) ? $meta->custom['step'] : '0.1';
         $input->getControlPrototype()->step($step);
     }
     if (isset($meta->conditions['min'])) {
         $input->getControlPrototype()->min($meta->conditions['min']);
     }
     if (isset($meta->conditions['max'])) {
         $input->getControlPrototype()->max($meta->conditions['max']);
     }
     $this->addConditions($input, $meta->conditions);
     return $input;
 }
开发者ID:voda,项目名称:formbuilder,代码行数:18,代码来源:NumberMapper.php

示例7: Form

require_once "../load.php";
require_once "example_library.php";
if (isset($_GET["logConsole"])) {
    require "logConsole.php";
}
use FileDownloader\Downloader\AdvancedDownloader;
use FileDownloader\FDTools;
use FileDownloader\FileDownload;
use Nette\Diagnostics\Debugger;
use Nette\Forms\Form;
// Generate form
$f = new Form("upload-form");
$f->getElementPrototype()->id = "frm";
$f->setMethod("GET");
$f->addSelect("speed", "Speed", array(1 => "1byte/s", 50 => "50bytes/s", 512 => "512bytes/s", 1 * FDTools::KILOBYTE => "1kb/s", 5 * FDTools::KILOBYTE => "5kb/s", 20 * FDTools::KILOBYTE => "20kb/s", 32 * FDTools::KILOBYTE => "32kb/s", 50 * FDTools::KILOBYTE => "50kb/s", 64 * FDTools::KILOBYTE => "64kb/s", 100 * FDTools::KILOBYTE => "100kb/s", 128 * FDTools::KILOBYTE => "128kb/s", 200 * FDTools::KILOBYTE => "200kb/s", 256 * FDTools::KILOBYTE => "256kb/s", 300 * FDTools::KILOBYTE => "300kb/s", 512 * FDTools::KILOBYTE => "512kb/s", 1 * FDTools::MEGABYTE => "1mb/s", 2 * FDTools::MEGABYTE => "2mb/s", 5 * FDTools::MEGABYTE => "5mb/s", 10 * FDTools::MEGABYTE => "10mb/s", 0 => "Unlimited"));
$f->addText("filename", "Filename")->addRule(Form::FILLED, "You must fill name!");
$f->addSelect("size", "Size", array(1 => "1MB", 4 => "4MB", 8 => "8MB", 16 => "16MB", 32 => "32MB", 64 => "64MB", 128 => "128MB", 256 => "256MB", 512 => "512MB"));
$f->addSelect("log", "Log called events?", array(0 => "No", 1 => "Yes (may cause CPU load)"));
$f->addSubmit("download", "Download!");
$f->setDefaults(array("speed" => 50, "filename" => "Some horrible file name - ěščřžýáíé.bin", "size" => 8, "log" => 1));
if ($f->isSubmitted() and $f->isValid()) {
    Debugger::enable(Debugger::PRODUCTION);
    // Log errors to file!
    $val = $f->getValues();
    $location = dirname(__FILE__) . "/cache/test-" . $val["size"] . "MB.tmp";
    if (!file_exists($location)) {
        generateFile($location, $val["size"] * 1024);
    }
    /* Interface with getters and setters */
    $file = new FileDownload();
    $file->sourceFile = $location;
开发者ID:jkuchar,项目名称:FileDownloader-example,代码行数:31,代码来源:index.php

示例8: MyTranslator

	'm' => 'male',
	'f' => 'female',
);



// Step 1: Define form with validation rules
$form = new Form;
// enable translator
$translator = new MyTranslator('gettext', __DIR__ . '/messages.mo', 'cs');
$translator->setLocale('cs');
$form->setTranslator($translator);

// group Personal data
$form->addGroup('Personal data');
$form->addText('name', 'Your name:')
	->setRequired('Enter your name');

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

$form->addRadioList('gender', 'Your gender:', $sex);

$form->addText('email', 'Email:')
	->setEmptyValue('@')
	->addCondition($form::FILLED) // conditional rule: if is email filled, ...
		->addRule($form::EMAIL, 'Incorrect email address'); // ... then check email

开发者ID:norbe,项目名称:examples,代码行数:29,代码来源:localization.php

示例9: Form

<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();
开发者ID:TomHetmer,项目名称:logs-db,代码行数:30,代码来源:new.php

示例10: array

if (@!include __DIR__ . '/../vendor/autoload.php') {
	die('Install packages using `composer update --dev`');
}

use Nette\Forms\Form;
use Nette\Forms\Controls;
use Tracy\Debugger;
use Tracy\Dumper;

Debugger::enable();


$form = new Form;

$form->addGroup('Personal data');
$form->addText('name', 'Your name')
	->setRequired('Enter your name');

$form->addRadioList('gender', 'Your gender', array(
	'male', 'female',
));

$form->addCheckboxList('colors', 'Favorite colors:', array(
	'red', 'green', 'blue',
));

$form->addSelect('country', 'Country', array(
	'Buranda', 'Qumran', 'Saint Georges Island',
));

$form->addCheckbox('send', 'Ship to address');
开发者ID:nakoukal,项目名称:fakturace,代码行数:31,代码来源:bootstrap2-rendering.php

示例11: date

		<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');
$form->addHidden('dbpassword');
$form->addHidden('dbname');
$form->addHidden('dbtablename');
$form->addSubmit('send', 'Uložit');
开发者ID:nakoukal,项目名称:raspi_www,代码行数:31,代码来源:index.php

示例12: myValidator

<?php

/**
 * Nette\Forms custom validator example.
 */
require_once __DIR__ . '/../../Nette/loader.php';
use Nette\Forms\Form, Nette\Debug;
Debug::enable();
// Step 0: Define custom validator
function myValidator($item, $arg)
{
    return $item->getValue() % $arg === 0;
}
// Step 1: Define form with validation rules
$form = new Form();
$form->addText('num1', 'Multiple of 8:')->addRule('myValidator', 'First number must be %d multiple', 8);
$form->addText('num2', 'Not multiple of 5:')->addRule(~'myValidator', 'Second number must not be %d multiple', 5);
// negative
$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;
        }
    }
开发者ID:jakubkulhan,项目名称:nette,代码行数:31,代码来源:custom-validator.php

示例13: die

 */
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
    die('Install packages using `composer install`');
}
use Nette\Forms\Form, Tracy\Debugger, Tracy\Dumper;
Debugger::enable();
// Define custom validator
class MyValidators
{
    static function divisibilityValidator($item, $arg)
    {
        return $item->value % $arg === 0;
    }
}
$form = new Form();
$form->addText('num1', 'Multiple of 8:')->setDefaultValue(5)->addRule('MyValidators::divisibilityValidator', 'First number must be %d multiple', 8);
$form->addText('num2', 'Not multiple of 5:')->setDefaultValue(5)->addRule(~'MyValidators::divisibilityValidator', 'Second number must not be %d multiple', 5);
// negative
$form->addSubmit('submit', 'Send');
if ($form->isSuccess()) {
    echo '<h2>Form was submitted and successfully validated</h2>';
    Dumper::dump($form->getValues());
    exit;
}
?>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Nette Forms custom validator example</title>
<link rel="stylesheet" media="screen" href="assets/style.css" />
<script src="http://nette.github.io/resources/js/netteForms.js"></script>
开发者ID:re1la2pse,项目名称:GromesProjekt,代码行数:30,代码来源:custom-validator.php

示例14: die

/**
 * Nette Forms basic example.
 */
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
    die('Install packages using `composer install`');
}
use Nette\Forms\Form;
use Tracy\Debugger;
use Tracy\Dumper;
use Nette\Utils\Html;
Debugger::enable();
$form = new Form();
// group Personal data
$form->addGroup('Personal data')->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.');
$form->addText('name', 'Your name:')->setRequired('Enter your name');
$form->addText('age', 'Your age:')->setRequired('Enter your age')->addRule($form::INTEGER, 'Age must be numeric value')->addRule($form::RANGE, 'Age must be in range from %d to %d', array(10, 100));
$form->addRadioList('gender', 'Your gender:', array('m' => 'male', 'f' => 'female'));
$form->addCheckboxList('colors', 'Favorite colors:', array('r' => 'red', 'g' => 'green', 'b' => 'blue'));
$form->addText('email', 'Email:')->setEmptyValue('@')->addCondition($form::FILLED)->addRule($form::EMAIL, 'Incorrect email address');
// ... then check email
// group Shipping address
$form->addGroup('Shipping address')->setOption('embedNext', TRUE);
$form->addCheckbox('send', 'Ship to address')->addCondition($form::FILLED)->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::FILLED)->setRequired('Enter your shipping address');
$countries = array('World' => array('bu' => 'Buranda', 'qu' => 'Qumran', 'st' => 'Saint Georges Island'), '?' => 'other');
$form->addSelect('country', 'Country:', $countries)->setPrompt('Select your country')->addConditionOn($form['send'], $form::FILLED)->setRequired('Select your country');
开发者ID:jave007,项目名称:test,代码行数:30,代码来源:basic-example.php

示例15: die

<?php

/**
 * Nette Forms and HTML5.
 */
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
    die('Install packages using `composer install`');
}
use Nette\Forms\Form;
use Tracy\Debugger;
use Tracy\Dumper;
Debugger::enable();
$form = new Form();
$form->addGroup();
$form->addText('query', 'Search:')->setType('search')->setAttribute('autofocus');
$form->addText('count', 'Number of results:')->setType('number')->setDefaultValue(10)->addRule($form::INTEGER, 'Must be numeric value')->addRule($form::RANGE, 'Must be in range from %d to %d', [1, 100]);
$form->addText('precision', 'Precision:')->setType('range')->setDefaultValue(50)->addRule($form::INTEGER, 'Precision must be numeric value')->addRule($form::RANGE, 'Precision must be in range from %d to %d', [0, 100]);
$form->addEmail('email', 'Send to email:')->setAttribute('autocomplete', 'off')->setAttribute('placeholder', 'Optional, but Recommended');
$form->addSubmit('submit', 'Send');
if ($form->isSuccess()) {
    echo '<h2>Form was submitted and successfully validated</h2>';
    Dumper::dump($form->getValues());
    exit;
}
?>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Nette Forms and HTML5</title>
<link rel="stylesheet" media="screen" href="assets/style.css" />
<script src="https://nette.github.io/resources/js/netteForms.js"></script>
开发者ID:nette,项目名称:forms,代码行数:30,代码来源:html5.php


注:本文中的Nette\Forms\Form::addText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。