Example #1
0
 public function actionAddReply($id, $internal)
 {
     $this->form = new AppForm($this, 'sendReply');
     $this->form->addHidden('tiket', $id);
     $this->form->addHidden('internal', $internal);
     $this->form->addTextArea('message', 'Odpověď/komentář:', 10);
     $this->form->addSubmit('send', 'Odeslat');
     $this->form->onSubmit[] = array($this, 'ReplyFormProcess');
     $this->template->form = $this->form;
 }
Example #2
0
 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;
 }
Example #3
0
<?php 
require_once '../../Nette/loader.php';
/*use Nette\ComponentContainer;*/
/*use Nette\Forms\Form;*/
/*use Nette\Forms\TextInput;*/
/*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
    $is_edit = 0;
    $button = 'Add New Product';
    //is this an edit?
    if (isset($_GET['id']) && (int) $_GET['id'] > 0) {
        $is_edit = 1;
        $id = (int) $_GET['id'];
        $product = new Product($id);
        $name = $product->product_name;
        $num = $product->product_num;
        $price = $product->price;
        $quantity = $product->quantity_on_hand;
        $desc = $product->description;
        $action = 'Edit';
        $button = 'Edit';
    }
    $title = $action . ' Product';
    $form = new Form();
    $form->addInput('product_name', 'Product Name', $name);
    $form->addInput('product_num', 'Product Number', $num);
    $form->addInput('price', 'Price', $price);
    $form->addInput('quantity', 'Quantity on Hand', $quantity);
    $form->addTextArea('desc', 'Description', $desc);
    if ($is_edit) {
        $form->addInput('id', '', $id, 'hidden');
    }
    $form->addInput('submit', null, $button, 'submit');
    $content = $form->render();
}
$content .= '<p class="back"><a href="product-list.php">Back to product list</a></p>';
//---Display---//
require_once '../template.php';
Example #5
0
 public function echoAddress()
 {
     $street;
     $type;
     $zip;
     $city = 0;
     $state;
     $foreign;
     $abbr;
     $success = true;
     $foreign_loc = 0;
     $primary = 1;
     if ($this->contact_item_id) {
         $sth = $this->db->prepare("SELECT con_addresses.`abbr`,`primary`,`street`,`type`,`zip`,`foreign`, " . "`city_id`,`loc_states`.`id` AS 'state' " . 'FROM `con_addresses` ' . 'LEFT OUTER JOIN `loc_cities` ON `con_addresses`.`city_id`=`loc_cities`.`id` ' . 'LEFT OUTER JOIN `loc_states` ON `loc_cities`.`state_id`=`loc_states`.`id` ' . 'WHERE `con_addresses`.`id`=?');
         $sth->execute(array($this->contact_item_id));
         if ($row = $sth->fetch()) {
             $abbr = $row['abbr'];
             $street = $row['street'];
             $type = $row['type'];
             $zip = $row['zip'];
             $city = $row['city_id'] ? $row['city_id'] : 0;
             $state = $row['state'];
             $primary = $row['primary'];
             if ($row['foreign']) {
                 $foreign_loc = 1;
                 $foreign = $row['foreign'];
             }
         } else {
             $success = false;
         }
     }
     if ($city == 0) {
         //pre-set state
         $state = $this->office_state_id;
         $city = $this->office_city_id;
     }
     if ($success) {
         $form = new Form('address');
         $form->addSelect('', 'type', array('Home' => 'Home', 'Work' => 'Work', 'Other' => 'Other'), $type);
         $form->addSwitch('Location:', 'foreign_loc', array('0' => 'United States', '1' => 'Foreign'), $foreign_loc, 'class="wideswitch"');
         $form->addText('Foreign city, state:', 'foreign', false, $foreign);
         $form->addSelect('State:', 'state', $this->stateArray(), $state);
         $form->addSelect('City:', 'city', $this->cityArray($state), $city);
         $form->addText('New city:', 'new_city', false);
         $form->addTextArea('Street:', 'street', true, $street);
         $form->addText('Zip:', 'zip', true, $zip, 'maxlength="10"');
         $form->addText('Abbreviation:', 'abbr', false, $abbr, 'maxlength="2"');
         $form->addSwitch('Primary:', 'primary', array('0' => 'No', '1' => 'Yes'), $primary);
         //, 'class="wideswitch"');
         $form->addHidden('id', $this->contact_item_id);
         $form->addHidden('contact_id', $this->contact_id);
         //$form->addHidden('callback', $this->form_callback);
         if ($this->contact_item_id) {
             $form->addDelete();
         }
         $form->echoForm();
     }
 }
Example #6
0
$locationScript .= '        $("#event_edit\\\\:\\\\:loc_t").val("%"+jQloc_s.val()+"%");' . PHP_EOL;
$locationScript .= '    }' . PHP_EOL;
$locationScript .= '});' . PHP_EOL;
$form = new Form('event_edit', $action, 'post');
$form->setIndent('    ');
$form->addScript($allDayBtns);
$form->addScript($locationScript);
$form->addBtnLine(array('close' => $closeBtn, 'save' => $saveBtn, 'apply' => $applyBtn));
$form->addTextField('ID', 'id', $ID, array('t' => 'ID of Event'), array('ro' => true));
$form->addTextField('Title', 'title', $title, array('t' => 'Title of Event (Unique)', 'p' => 'Event Title'), array('r' => true, 'v' => true, 'vm' => array('textfieldRequiredMsg' => array('m' => 'An Event Title is required.', 's' => B_T_FAIL), 'textfieldMinCharsMsg' => array('m' => 'An Event Title is required.', 's' => B_T_FAIL), 'textfieldMaxCharsMsg' => array('m' => 'Event title is limited to 100 chars.', 's' => B_T_FAIL)), 'vo' => 'minChars: 0, maxChars: 100, validateOn:["blur"]'));
$form->addButtonGroup('Published', 'enable', array(array('i' => 'enabledY', 's' => B_T_SUCCESS, 'v' => 1, 'l' => 'Yes <span class="' . B_ICON . ' ' . B_ICON . '-eye-open"></span>', 'c' => $enabled), array('i' => 'enabledN', 's' => B_T_FAIL, 'v' => 0, 'l' => 'No <span class="' . B_ICON . ' ' . B_ICON . '-eye-close"></span>', 'c' => not($enabled))), array('t' => 'Publish an event to view it on the site.'));
$form->addTextField('Start Date', 'start_d', substr($starts, 0, 10), array('t' => 'Date event starts', 'p' => 'Start Date'), array('r' => true, 'v' => true, 't' => 'date', 'vm' => array('textfieldRequiredMsg' => array('m' => 'An Event Start Date is required.', 's' => B_T_FAIL), 'textfieldInvalidFormatMsg' => array('m' => 'Incorrect date format.', 's' => B_T_FAIL)), 'vo' => 'validateOn:["blur"], format: "yyyy-mm-dd"'));
$form->addTextField('Start Time', 'start_t', substr($starts, 11), array('t' => 'Time event starts', 'p' => 'Start Time'), array('r' => true, 'v' => true, 't' => 'time', 'vm' => array('textfieldRequiredMsg' => array('m' => 'An Event Start Time is required.', 's' => B_T_FAIL), 'textfieldInvalidFormatMsg' => array('m' => 'Incorrect time format.', 's' => B_T_FAIL)), 'vo' => 'validateOn:["blur"], format: "HH:mm:ss"'));
$form->addTextField('Finish Date', 'finish_d', substr($finish, 0, 10), array('t' => 'Date event finishes', 'p' => 'Finish Date'), array('r' => true, 'v' => true, 't' => 'date', 'vm' => array('textfieldRequiredMsg' => array('m' => 'An Event Finish Date is required.', 's' => B_T_FAIL), 'textfieldInvalidFormatMsg' => array('m' => 'Incorrect date format.', 's' => B_T_FAIL)), 'vo' => 'validateOn:["blur"], format: "yyyy-mm-dd"'));
$form->addTextField('Finish Time', 'finish_t', substr($finish, 11), array('t' => 'Time event finishes', 'p' => 'Finishes Time'), array('r' => true, 'v' => true, 't' => 'time', 'vm' => array('textfieldRequiredMsg' => array('m' => 'An Event Finish Time is required.', 's' => B_T_FAIL), 'textfieldInvalidFormatMsg' => array('m' => 'Incorrect time format.', 's' => B_T_FAIL)), 'vo' => 'validateOn:["blur"], format: "HH:mm:ss"'));
$form->addButtonGroup('All Day', 'allday', array(array('i' => 'alldayY', 's' => B_T_SUCCESS, 'v' => 1, 'l' => 'Yes', 'c' => $allDay), array('i' => 'alldayN', 's' => B_T_FAIL, 'v' => 0, 'l' => 'No', 'c' => not($allDay))), array('t' => 'Is the event all day?'));
$form->addSelect('Location', 'loc_s', $locations, array('t' => 'The location of the event. Select a stored event, or use an \'other\' location.'), array('r' => true, 'v' => true, 'vo' => 'validateOn:["blur"]', 'vm' => array()));
$form->addTextField('Other Location', 'loc_t', $location, array('t' => 'Enter an \'Other\' location here'), array('classes' => array('hidden')));
$form->addTextArea('Details', 'details', $details, 6, array('t' => 'Details for the event (Recommended unless linking event)', 'p' => 'Details to follow here...'), array('vm' => array('textareaMaxCharsMsg' => array('m' => 'Event details are limited to 500 chars.', 's' => B_T_FAIL)), 'vo' => 'maxChars: 500, useCharacterMasking:false, validateOn:["blur", "change"]', 'c' => true, 'v' => true, 'c' => true));
$form->addTextField('Link', 'link', $link, array('t' => 'Link to event details when user clicks on event in calendar', 'p' => 'http(s)://www.example.com'), array('r' => false, 'v' => true, 't' => 'url', 'vm' => array('textfieldInvalidFormatMsg' => array('m' => 'Incorrect link format.', 's' => B_T_FAIL)), 'vo' => 'validateOn:["blur", "change"]'));
$form->addBtnLine(array('close' => $closeBtn, 'save' => $saveBtn, 'apply' => $applyBtn));
$form->build();
?>

<div class="row pane">
  <div class="col-sm-12 col-md-11 col-lg-11 col-lg-offset-1 col-md-offset-1">
<?php 
print $form->getForm();
?>
  </div>
</div>
Example #7
0
 public function echoNoteEdit()
 {
     $success = true;
     $today = new DateTime();
     $date = $today->format('n-j-Y');
     $body;
     if ($this->page_type != 'new') {
         $sth = $this->db->prepare("SELECT `body`, " . "DATE_FORMAT(`date`, '%c-%e-%Y') AS 'date_format' " . 'FROM `notes` WHERE `id`=?');
         $sth->execute(array($this->id));
         if ($row = $sth->fetch()) {
             $id = $this->id;
             $body = $row['body'];
             $date = $row['date_format'];
         } else {
             $success = false;
         }
     }
     if ($success) {
         $form = new Form('note');
         // cant directly comment out below regex
         if (false) {
             if ($this->platform == 'and') {
                 $nl = preg_replace('#<br\\s*/?>#i', "\r\n", $body);
                 $form->addTextArea('', 'bodysource', true, $nl);
             } else {
                 $form->addTextArea('', 'body', true, $body);
             }
         }
         // end comment out
         $form->addTextArea('', 'body', true, $body);
         $form->addDate('Date:', 'date', true, true, $date);
         if ($this->page_type == 'edit' && ($this->admin || $this->emp_id == $this->folder_emp_id || $this->office_admin && $this->folder_office_id == $this->office_id)) {
             $move_arr = $this->moveFolderArr($this->parent_folder_id);
             if (count($move_arr) > 1) {
                 //$form->addHeading('Move');
                 $form->addSelect('Move to:', 'move', $move_arr);
             }
             $form->addDelete();
         }
         $form->addHidden('id', $id);
         $form->addHidden('folder_id', $this->parent_folder_id);
         $form->echoForm();
         // add link popup
         echo '<div data-role="popup" id="link-popup" class="ui-content">' . '<form>' . '<h4>Create link</h4>' . '<label for="link-url">URL</label>' . '<input name="link-url" id="link-url" type="text">' . '<button id="link-ok">OK</button>' . '</form>' . '</div>';
     }
 }
<?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", $templateEntity);
$form->addSection("Template Management");
$form->addText("name", "Name", 60, MANDATORY);
$form->addTextArea("dtml", "Template", 20, 50);
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();
?>