本文整理汇总了PHP中Form::addText方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addText方法的具体用法?PHP Form::addText怎么用?PHP Form::addText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form::addText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exampleForm
private function exampleForm()
{
$countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'FR' => 'France', 'DE' => 'Germany', 'GR' => 'Greece', 'HU' => 'Hungary', 'IE' => 'Ireland', 'IT' => 'Italy', 'NL' => 'Netherlands', 'PL' => 'Poland', 'SK' => 'Slovakia', 'ES' => 'Spain', 'CH' => 'Switzerland', 'UA' => 'Ukraine', 'GB' => 'United Kingdom'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other');
$sex = array('m' => 'male', 'f' => 'female');
// Step 1: Define form with validation rules
$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:', 35)->addRule(Form::FILLED, 'Enter your name');
$form->addText('age', 'Your age:', 5)->addRule(Form::FILLED, 'Enter your age')->addRule(Form::INTEGER, 'Age must be numeric value')->addRule(Form::RANGE, 'Age must be in range from %.2f to %.2f', array(9.9, 100));
$form->addRadioList('gender', 'Your gender:', $sex);
$form->addText('email', 'E-mail:', 35)->setEmptyValue('@')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Incorrect E-mail Address');
// ... 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:', 35);
$form->addText('city', 'City:', 35)->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:', 20)->addRule(Form::FILLED, 'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3);
$form->addPassword('password2', 'Reenter password:', 20)->addConditionOn($form['password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']);
$form->addFile('avatar', 'Picture:')->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Uploaded file is not image', 'image/*');
$form->addHidden('userid');
$form->addTextArea('note', 'Comment:', 30, 5);
// group for buttons
$form->addGroup();
$form->addSubmit('submit1', '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;
}
}
} else {
// not submitted, define default values
$defaults = array('name' => 'John Doe', 'userid' => 231, 'country' => 'CZ');
$form->setDefaults($defaults);
}
return $form;
}
示例2: actionDefault
public function actionDefault($backlink)
{
$this->backlink = $backlink;
$this->form = new AppForm($this, 'login');
$this->form->addText('userName', 'Uživatelské jméno:')->addRule(Form::FILLED, 'Uživatelské jméno musí být vyplněno.');
$this->form->addPassword('password', 'Přístupové heslo:')->addRule(Form::FILLED, 'Přístupové heslo musí být vyplněno.');
//->addRule(Form::MIN_LENGTH, 'Heslo musí být minimálně %d znaků', 12);
$this->form->addSubmit('login', 'Přihlásit');
$this->form->onSubmit[] = array($this, 'FormSubmitted');
$this->template->form = $this->form;
if (!isset($this->template->result)) {
$this->template->result = "";
}
$this->user->setAuthenticationHandler(new UsersModel());
}
示例3: createComponentForm
protected function createComponentForm()
{
$form = new Form();
$form->addText('title', 'Titulek', 80)->addRule(Form::FILLED, 'Vyplňte prosím titulek!');
$form->addTextarea('text', 'Text', 50, 20)->addRule(Form::FILLED, 'Vyplňte prosím text článku!')->getControlPrototype()->setClass('wysiwyg');
$form->addSubmit('ok', 'Upravit')->getControlPrototype()->data['confirm'] = "Opravdu chcete upravit tento clanek?";
$form->onSuccess[] = callback($this, 'process');
return $form;
}
示例4: loginForm
private function loginForm()
{
$form = new Form();
$form->setAction(Lib_Link::build('login/login'));
$form->addText('userLogin', 'Jmeno:', 10)->addRule(Form::FILLED, 'Vloz svoje uzivatelske jmeno.');
$form->addPassword('userPassword', 'Heslo:', 10)->addRule(Form::FILLED, 'Vloz tvoje heslo.')->addRule(Form::MIN_LENGTH, 'Heslo musi byt dlouhe minimalne %d znaku.', 3);
$form->addSubmit('login', 'Prihlasit');
return $form . '';
}
示例5: actionUserChange
public function actionUserChange($akce = 0, $id = -1)
{
$this->access($id);
//kvůli Nette - action je vyhrazeno
$action = $akce;
$this->verifyUser();
$this->form = new AppForm($this, 'userChange');
//TODO: Definovat zprávu
//$this->form->addProtection($this->formProtectedMessage);
$msg = 'Heslo musí obsahovat VELKÁ a malá písmena a číslice!';
$this->form->addGroup('Přihlašovací informace');
$this->form->addText('userName', 'Uživatelské jméno:')->addRule(Form::FILLED, 'Uživatelské jméno musí být vyplněno.')->addRule(Form::MIN_LENGTH, 'Uživatelské jméno musí mít alespoň %d znaky.', 4)->addRule(Form::MAX_LENGTH, 'Uživatelské jméno může mít nejvýše %d znaků.', 20);
if ($action > 0) {
$this->form['userName']->setDisabled(true);
}
if ($action != 1) {
$this->form->addPassword('password1', 'Heslo:')->addRule(Form::FILLED, 'Heslo musí být vyplněno.')->addRule(Form::MIN_LENGTH, 'Heslo musí mít alespoň %d znaků.', 8)->addRule(Form::MAX_LENGTH, 'Heslo může mít nejvýše %d znaků', 50)->addRule(Form::REGEXP, $msg, '/[A-Z]+/')->addRule(Form::REGEXP, $msg, '/[a-z]+/')->addRule(Form::REGEXP, $msg, '/[0-9]+/');
$this->form->addPassword('password2', 'Přístupové heslo (pro kontrolu):')->addRule(Form::EQUAL, 'Zadaná hesla se neshodují.', $this->form['password1']);
$this->form->addText('navrhHesla', 'Navrhované heslo:');
}
if ($action < 2) {
$this->form->addGroup('Osobní informace');
$this->form->addText('firstName', 'Jméno:')->addRule(Form::FILLED, 'Jméno musí být vyplněno.');
$this->form->addText('surname', 'Přijmení:')->addRule(Form::FILLED, 'Přijmení musí být vyplněno.');
$this->form->addText('title', 'Titul:')->addRule(Form::MAX_LENGTH, 'Titul může mít nejvýše %d znaků.', 10);
$this->form->addGroup('Kontaktní informace');
$this->form->addText('email', 'E-mail:')->addRule(Form::FILLED, 'E-mail musí být vyplněn.')->addRule(Form::EMAIL, 'Zadaný e-mail není platný.');
$this->form->addText('icq', 'ICQ:')->addCondition(Form::FILLED)->addRule(Form::NUMERIC, 'ICQ musí být číslo.')->addRule(Form::MAX_LENGTH, 'ICQ může mít nejvýše %d znaků.', 10);
$this->form->addText('skype', 'Skype:')->addRule(Form::MAX_LENGTH, 'Skype může mát nejvýše %d znaků.', 50);
$this->form->addText('mobile', 'Mobilní telefon:')->addCondition(Form::FILLED)->addRule(Form::NUMERIC, 'Mobilní telefon musí být číslo.')->addRule(Form::MAX_LENGTH, 'Mobilní telefon může mít nejvýše %d znaků.', 20);
$roles = UsersModel::getRoles();
// Zobrazujeme pouze tehdy je-li uživatel administrátor - aby si uživatel sám nemohl měnit skupinu
if ($this->user->isInRole('Administrator')) {
$this->form->addGroup('Přístupová práva (může být vybráno více skupin)');
$this->form->addMultiSelect('prava', 'Přístupová práva:', $roles, 2);
}
}
$this->form->onSubmit[] = array($this, 'UserFormSubmitted');
$this->form->addHidden('action')->setValue($action);
if ($action > 0) {
$data = UsersModel::getUser($id);
$data['navrhHesla'] = UsersModel::genPass();
// Nastavíme výchozí hodnoty pro formulář
$this->form->setDefaults($data);
$this->form->addHidden('id')->setValue($id);
$this->form->addSubmit('ok', 'Aktualizovat');
// ->onClick[] = array($this, 'OkClicked'); // nebo 'OkClickHandler'
} else {
$data['navrhHesla'] = UsersModel::genPass();
// Nastavíme výchozí hodnoty pro formulář
$this->form->setDefaults($data);
$this->form->addSubmit('ok', 'Vytvořit');
// ->onClick[] = array($this, 'OkClicked'); // nebo 'OkClickHandler'
}
$this->template->form = $this->form;
}
示例6: defaultAction
function defaultAction()
{
$subjects = array(1 => array('id' => 1, 'title' => s('General question')), 2 => array('id' => 2, 'title' => s('Bug report')), 3 => array('id' => 3, 'title' => s('Collaboration or partership')), 4 => array('id' => 4, 'title' => s('Idea')), 5 => array('id' => 5, 'title' => s('Other')));
$html = '';
$errors = array();
$is_posted = request_int('is_posted');
$jump_to = 'feedback_name';
if ($is_posted) {
if (!count($errors) && !request_str('email')) {
$errors[] = s('Please, enter your email');
$jump_to = 'feedback_email';
}
if (!count($errors) && request_str('email') && !filter_var(request_str('email'), FILTER_VALIDATE_EMAIL)) {
$errors[] = s('Please, provide correct email address. For example: john@gmail.com');
$jump_to = 'feedback_email';
}
if (!count($errors) && !request_str('message')) {
$errors[] = s('Enter the message.');
$jump_to = 'feedback_password';
}
if (!count($errors)) {
$data = array('{name}' => request_str('name'), '{email}' => request_str('email'), '{subject}' => $subjects[request_int('subject_id')]['title'], '{message}' => request_str('message'));
$message = str_replace(array_keys($data), array_values($data), 'Name: {name}
Email: {email}
Subject: {subject}
{message}
' . $_SERVER['REMOTE_ADDR'] . ' ' . date('r'));
core::$sql->insert(array('message' => core::$sql->s($message), 'insert_stamp' => core::$sql->i(time())), DB . 'feedback');
require_once '../mod/lib.mail.php';
foreach (array('info@metro4all.ru') as $email) {
mail_send(request_str('name'), request_str('email'), $email, 'Metro4all.org - ' . $subjects[request_int('subject_id')]['title'], $message, false);
}
go(Core::$config['http_home'] . 'feedback/?action=ok');
}
}
$page = new PageCommon(s('Feedback'));
$html .= $page->start();
$html .= '<div class="row"><div class="col-md-offset-2 col-md-8"><h2>' . s('Feedback') . '</h2>';
if (count($errors)) {
$html .= '<div class="alert alert-danger"><p>' . escape($errors[0]) . '</p></div>';
}
$form = new Form('feedback', false, 'post');
$html .= '<div class="well">' . $form->start() . $form->addVariable('is_posted', 1) . $form->addString('name', s('Name'), $is_posted ? request_str('name') : '') . $form->addString('email', s('E-mail'), $is_posted ? request_str('email') : '', array('is_required' => true)) . $form->addSelect('subject_id', s('Subject'), $is_posted ? request_int('subject_id') : 1, array('data' => $subjects)) . $form->addText('message', s('Message'), $is_posted ? request_str('message') : '', array('is_required' => true, 'style' => 'height:200px')) . $form->submit(s('Send')) . '</div>';
$html .= '<script> $(document).ready(function() { $("#' . $jump_to . '").focus(); }); </script>';
$html .= '</div></div>';
$html .= $page->stop();
return $html;
}
示例7: Skin
<?php
session_start();
require "include/template2.inc.php";
require "include/beContent.inc.php";
require "include/auth.inc.php";
$main = new Skin();
$form = new Form("dataEntry", $layerEntity);
$form->addSection("Layer Management");
$form->addText("title", "Title", 40, MANDATORY);
$form->addText("subtitle", "Subtitle", 40, MANDATORY);
$form->addEditor("description", "Text", 10, 50);
$form->addFile("foto", "Foto");
$form->addSelectFromReference2($bgEntity, "bg_id", "Background");
$form->addSelectFromReference2($pageEntity, "page_id", "Page");
$form->addPosition("position", "Order", "title");
if (!isset($_REQUEST['action'])) {
$_REQUEST['action'] = "edit";
}
switch ($_REQUEST['action']) {
case "add":
$main->setContent("body", $form->addItem());
break;
case "edit":
$main->setContent("body", $form->editItem());
break;
}
$main->close();
?>
示例8: Skin
<?php
session_start();
require "include/template2.inc.php";
require "include/beContent.inc.php";
require "include/auth.inc.php";
$main = new Skin();
$form = new Form("albumform", $albumEntity);
$form->addSection("Album Management");
$form->addText("title", "Album Name", 40, MANDATORY);
$form->addEditor("description", "Album Description", 10, 100);
$form->addPosition("position", "Order", "title");
if (!isset($_REQUEST['action'])) {
$_REQUEST['action'] = "edit";
}
switch ($_REQUEST['action']) {
case "add":
$main->setContent("body", $form->addItem());
break;
case "edit":
$main->setContent("body", $form->editItem());
break;
}
$main->close();
?>
示例9: Skin
<?php
session_start();
require "include/template2.inc.php";
require "include/beContent.inc.php";
require "include/auth.inc.php";
$main = new Skin("default");
$form = new Form("dataEntry", $contattiEntity);
$form->addSection("Contact Management");
$form->addText("email", "email", 100, MANDATORY);
$form->addFile("Photo", "Foto");
if (!isset($_REQUEST['action'])) {
$_REQUEST['action'] = "edit";
}
switch ($_REQUEST['action']) {
case 'add':
$main->setContent("body", $form->addItem());
break;
case "edit":
$main->setContent("body", $form->editItem());
break;
}
$main->close();
示例10: array
/**
* Nette\Forms example 1
*
* - separated form and rules definition
* - manual form rendering
*/
require '../../Nette/loader.php';
/*use Nette\Forms\Form;*/
/*use Nette\Debug;*/
Debug::enable();
$countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'FR' => 'France', 'DE' => 'Germany', 'GR' => 'Greece', 'HU' => 'Hungary', 'IE' => 'Ireland', 'IT' => 'Italy', 'NL' => 'Netherlands', 'PL' => 'Poland', 'SK' => 'Slovakia', 'ES' => 'Spain', 'CH' => 'Switzerland', 'UA' => 'Ukraine', 'GB' => 'United Kingdom'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other');
$sex = array('m' => 'male', 'f' => 'female');
// Step 1: Define form
$form = new Form();
$form->addText('name', 'Your name:', 35);
$form->addText('age', 'Your age:', 5);
$form->addRadioList('gender', 'Your gender:', $sex);
$form->addText('email', 'E-mail:', 35)->setEmptyValue('@');
$form->addCheckbox('send', 'Ship to address');
$form->addText('street', 'Street:', 35);
$form->addText('city', 'City:', 35);
$form->addSelect('country', 'Country:', $countries)->skipFirst();
$form->addPassword('password', 'Choose password:', 20);
$form->addPassword('password2', 'Reenter password:', 20);
$form->addFile('avatar', 'Picture:');
$form->addHidden('userid');
$form->addTextArea('note', 'Comment:', 30, 5);
$form->addSubmit('submit1', 'Send');
// Step 1b: Define validation rules
$form['name']->addRule(Form::FILLED, 'Enter your name');
示例11: Skin
<?php
session_start();
require "include/template2.inc.php";
require "include/beContent.inc.php";
require "include/auth.inc.php";
$main = new Skin();
$form = new Form("dataEntry", $servicesEntity, POST);
$form->addSection("Service Management");
$form->addText("name", "Name", 40, MANDATORY);
$form->addText("script", "Script", 60, MANDATORY);
$form->addEditor("des", "Description", 15, 40);
//$form->addFile("icon", "Icon");
$form->addSection("Menu");
$form->addText("entry", "Menu Entry", 40, MANDATORY);
$form->addSelectFromReference2($servicecategoryEntity, "servicecategory", "Category");
$form->addHierarchicalPosition("position", "Position", "name", "servicecategory");
$form->addCheck("Visible", ":visible:*:*");
$form->addSection("Data filtering");
$form->addSelectFromReference2($entitiesEntity, "id_entities", "Entity");
$form->restrictReference("id_entities", "owner = '1' or name = '{$usersEntity->name}' or name = '{$logEntity->name}'");
$form->addSelectFromReference2($groupsEntity, "superuser_group", "Superuser Group");
$form_groups = new Form("dataEntry2", $servicesGroupsRelation);
$form->addSection("Groups");
$form_groups->addRelationManager("groups", "Groups");
$form->triggers($form_groups);
if (!isset($_REQUEST['action'])) {
$_REQUEST['action'] = "edit";
}
switch ($_REQUEST['action']) {
case "add":
示例12: Skin
<?php
session_start();
require "include/template2.inc.php";
require "include/beContent.inc.php";
require "include/auth.inc.php";
$main = new Skin();
$form = new Form("dataEntry", $channelEntity);
$form->addSection("Picture Management");
$form->addText("title", "Title", 50, MANDATORY);
$form->addTextarea("description", "Description", 2, 100);
$form->addSelectFromReference2($albumEntity, "title_album", "Select Album", 100);
$form->addSelectFromReference2($usersEntity, "username_users", "Username", 100);
if (!isset($_REQUEST['action'])) {
$_REQUEST['action'] = "edit";
}
switch ($_REQUEST['action']) {
case "add":
$main->setContent("body", $form->addItem());
break;
case "edit":
$main->setContent("body", $form->editItem());
break;
}
$main->close();
?>
示例13: echoClientEdit
public function echoClientEdit()
{
$id;
$contact_id;
$sex = 'm';
$first_name;
$middle_name;
$last_name;
$suffix;
$ssn;
$dob;
$aka;
$dba;
$success = true;
if ($this->page_type == 'edit') {
$sth = $this->db->prepare("SELECT `contact_id`,`contacts`.`name` AS 'last_name'," . "`first_name`,`middle_name`,`suffix`,`sex`,`ssn`,`aka`,`dba`, " . "DATE_FORMAT(`dob`, '%c-%e-%Y') AS 'dob_format' " . 'FROM `clients` ' . 'JOIN `contacts` ON `clients`.`contact_id`=`contacts`.`id` ' . 'WHERE `clients`.`id`=?');
$sth->execute(array($this->id));
if ($row = $sth->fetch()) {
$id = $this->id;
$contact_id = $row['contact_id'];
$first_name = $row['first_name'];
$middle_name = $row['middle_name'];
$last_name = $row['last_name'];
$suffix = $row['suffix'];
$sex = $row['sex'] ? $row['sex'] : 'none';
$ssn = $row['ssn'];
$dob = $row['dob_format'];
$aka = $row['aka'];
$dba = $row['dba'];
} else {
$success = false;
}
}
if ($success) {
$form = new Form('client');
$form->addHeading('Name');
$form->addSelect('', 'sex', array('m' => 'Male', 'f' => 'Female', 'none' => 'None'), $sex);
$form->addText('First name:', 'first_name', false, $first_name);
$form->addText('Middle:', 'middle_name', false, $middle_name);
$form->addText('Last (or biz name):', 'name', true, $last_name);
$form->addText('Suffix (Jr/Sr/etc):', 'suffix', false, $suffix);
$form->addHeading('Info');
$form->addDate('Date of birth:', 'dob', false, true, $dob);
$form->addText('SSN (no dashes):', 'ssn', false, $ssn, 'minlength="9" maxlength="9" digits="true"');
$form->addText('AKA:', 'aka', false, $aka);
$form->addText('DBA:', 'dba', false, $dba);
$form->addHidden('id', $id);
$form->addHidden('contact_id', $contact_id);
if ($this->admin && $this->page_type == 'edit') {
$form->addDelete();
}
$form->echoForm();
}
}
示例14: Skin
<?php
session_start();
require "include/template2.inc.php";
require "include/beContent.inc.php";
require "include/auth.inc.php";
$main = new Skin();
$form = new Form("dataEntry", $catModuleEntity);
$form->addSection("Module Category Management");
$form->addText("name", "Name", 40, MANDATORY);
$form->addPosition("position", "Order", "name");
if (!isset($_REQUEST['action'])) {
$_REQUEST['action'] = "edit";
}
switch ($_REQUEST['action']) {
case "add":
$main->setContent("body", $form->addItem());
break;
case "edit":
$main->setContent("body", $form->editItem());
break;
}
$main->close();
?>
示例15: Skin
<?php
session_start();
require "include/template2.inc.php";
require "include/beContent.inc.php";
require "include/auth.inc.php";
$main = new Skin();
$form = new Form("dataEntry", $testEntity);
$form->addSection("Testimonial Management");
$form->addText("name", "Name", 60, MANDATORY);
$form->addPosition("posizione", "Posizione", "name");
$form->addText("edizione", "Edizione", 20, MANDATORY);
$form->addText("affiliazione", "Affiliazione", 60, MANDATORY);
$form->addFile("photo", "Foto");
$form->addTextarea("messaggio", "Messaggio", 10, 60);
if (!isset($_REQUEST['action'])) {
$_REQUEST['action'] = "edit";
}
switch ($_REQUEST['action']) {
case "add":
$main->setContent("body", $form->addItem());
break;
case "edit":
$main->setContent("body", $form->editItem());
break;
}
$main->close();
?>