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:'******'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:'******'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; }
/*use Nette\Forms\FormContainer;*/ /*use Nette\Environment;*/ /*use Nette\Debug;*/ Debug::enable(); $countries = array('Select your country', 'Europe' => array(1 => 'Czech Republic', 2 => 'Slovakia'), 3 => 'USA', 4 => 'other'); $sex = array('m' => 'male', 'f' => 'female'); $form = new Form(); $form->addText('name', 'Your name:', 35); // item name, label, size, maxlength $form->addTextArea('note', 'Comment:', 30, 5); $form->addRadioList('gender', 'Your gender:', $sex); $form->addCheckbox('send', 'Ship to address'); $form->addSelect('country', 'Country:', $countries)->skipFirst(); $form->addMultiSelect('countrym', 'Country:', $countries); $form->addPassword('password', 'Choose password:'******'avatar', 'Picture:'); $form->addHidden('userid'); $sub = $form->addContainer('firstperson'); $sub->addText('age', 'Your age:', 5); $sub = $form->addContainer('secondperson'); $sub->addText('age', 'Your age:', 5); $sub->addFile('avatar', 'Picture:'); $form->addSubmit('submit1', 'Send'); $_SERVER['REQUEST_METHOD'] = 'POST'; /* valid data $_POST = array( 'name' => 'string', 'note' => 'textbox', 'gender' => 'm', 'send' => 'on', 'country' => '1',
<?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(); ?>
<?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", $iconEntity); $form->addSection("Iconogram Management"); $form->addText("name", "Name", 40, MANDATORY); $form->addFile("icon", "Icon"); 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(); ?>
<?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(); ?>
$channelEntity = new Entity($database,"bc_channel"); $channelEntity->setPresentation("title"); $channelEntity->addField("title",VARCHAR,50,MANDATORY); $channelEntity->addField("link",VARCHAR,100,MANDATORY); $channelEntity->addField("description",VARCHAR,150,MANDATORY); $channelEntity->addReference($lanEntity, "language"); $channelEntity->addField("image_title",VARCHAR,50); $channelEntity->addField("image_link",VARCHAR,100); $channelEntity->addField("image",FILE); $channelEntity->connect(); */ $form->addSection("Image Management"); $form->addText("image_title", "Title", 50); $form->addFile("image", "Image"); 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(); ?>
$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:'******'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:'******'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;
<?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", $bgEntity); $form->addSection("Background Management"); $form->addText("name", "Name", 40, MANDATORY); $form->addFile("file", "Foto (1020x450)"); 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(); ?>
<?php session_start(); require "include/beContent.inc.php"; require "include/auth.inc.php"; require_once 'include/content.inc.php'; require_once realpath(dirname(__FILE__)) . '/include/view/template/InitGraphic.php'; $main = new Skin("system"); InitGraphic::getInstance()->createSystemGraphic($main); $form = new Form("dataEntry", $fileToFolderEntity); $form->addTitleForm("File to Folder Management"); $form->addSection('file details'); $form->addFile("file", "Scegli il file"); $main->setContent("body", $form->requestAction()); $main->close();
<?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", $doodleEntity); $form->addSection("Doodle Management"); $form->addText("name", "Name", MANDATORY); $form->addFile("picture", "Picture"); $form->addCheck("Active", ":active:*:CHECKED"); $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(); ?>
<?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", $slideEntity); $form->addSection("Slide Management"); $form->addText("title", "Title", 60, MANDATORY); $form->addText("subtitle", "Subtitle", 80, MANDATORY); //$form->addSlider("xtext", "X", "100", "720"); //$form->addSlider("ytext", "Y", "0", "350"); $form->addSection("Background and Foreground Images & Positioning"); $form->addFile("bgimage", "Background"); $form->addFile("fgimage", "Picture"); $form->addSlider("x", "X", "0", "1020"); $form->addSlider("y", "Y", "0", "450"); $form->addSection("Ordering"); $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; }
<?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", $moduleEntity); $form->addSection("Module Management"); $form->addText("name", "Name", 40, MANDATORY); $form->addEditor("description", "Description", 7, 70); $form->addPosition("position", "Order", "name"); $form->addFile("file", "Document"); $form->addSelectFromReference2($catModuleEntity, "category", "Category"); 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(); ?>