public function testNoTranslate()
 {
     $form = new Form();
     $form->setTranslator(new MockTranslator());
     $form->addSelect('translateFalse', 'label', ['a', 'b', 'c'])->setTranslate(FALSE)->setPrompt('Prompt');
     $form->addSelect('translateFalseEmptyPrompt', 'label', ['a', 'b', 'c'])->setTranslate(FALSE);
     $form->addSelect('translate', 'label', ['a', 'b', 'c'])->setTranslate(TRUE)->setPrompt('Prompt');
     $form->addSelect('translateEmptyPrompt', 'label', ['a', 'b', 'c'])->setTranslate(TRUE);
     // Translate false
     $form['translateFalse']->getLabel();
     $form['translateFalse']->getControl();
     $this->assertSame(['label', 'Prompt'], MockTranslator::$toTranslate);
     MockTranslator::$toTranslate = [];
     // Translate false, empty prompt
     $form['translateFalseEmptyPrompt']->getLabel();
     $form['translateFalseEmptyPrompt']->getControl();
     $this->assertSame(['label'], MockTranslator::$toTranslate);
     MockTranslator::$toTranslate = [];
     // Translate
     $form['translate']->getLabel();
     $form['translate']->getControl();
     $this->assertSame(['label', 'Prompt', 'a', 'b', 'c'], MockTranslator::$toTranslate);
     MockTranslator::$toTranslate = [];
     // Translate, empty prompt
     $form['translateEmptyPrompt']->getLabel();
     $form['translateEmptyPrompt']->getControl();
     $this->assertSame(['label', 'a', 'b', 'c'], MockTranslator::$toTranslate);
     MockTranslator::$toTranslate = [];
 }
Example #2
0
 public function actionChangeDepartment($id)
 {
     $this->form = new AppForm($this, 'chngDepartment');
     $this->form->addHidden('tiket', $id);
     $this->form->addSelect('department', "Zvolte oddělení:", UsersModel::getAllDepartments());
     $this->form->addSubmit('forward', 'Předat');
     $this->form->onSubmit[] = array($this, 'DepartmentFormProcess');
     $this->template->form = $this->form;
 }
Example #3
0
    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('*****@*****.**') 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;
    }
Example #4
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 #5
0
/*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
$_POST = array(
	'name' => 'string',
	'note' => 'textbox',
Example #6
0
    function registerAction()
    {
        $html = '';
        $errors = array();
        $is_posted = request_int('is_posted');
        $jump_to = 'register_title';
        if ($is_posted) {
            // $captcha_code = request_str('captcha_code');
            if (!count($errors) && !request_int('language_id')) {
                $errors[] = s('Пожалуйста, выберите язык.');
                $jump_to = 'register_language_id';
            }
            if (!count($errors) && !request_str('email')) {
                $errors[] = s('Пожалуйста, укажите e-mail.');
                $jump_to = 'register_email';
            }
            if (!count($errors) && request_str('email') && !filter_var(request_str('email'), FILTER_VALIDATE_EMAIL)) {
                $errors[] = s('Пожалуйста, укажите корректный e-mail. Например: john@gmail.com');
                $jump_to = 'register_email';
            }
            if (!count($errors) && core::$sql->value('count(*)', DB . 'user', 'lower(email)=lower(' . core::$sql->s(request_str('email')) . ')')) {
                $errors[] = s('Пользователь с таким e-mail уже зарегистрирован. Пожалуйста, укажите другой.');
                $jump_to = 'register_email';
            }
            if (!count($errors) && !request_str('password')) {
                $errors[] = s('Пожалуйста, укажите пароль.');
                $jump_to = 'register_password';
            }
            if (!count($errors) && request_str('password') != request_str('password2')) {
                $errors[] = s('Введенные пароли не совпадают. Пожалуйста, попробуйте еще раз.');
                $jump_to = 'register_password';
            }
            // if(captcha_compare(request_str('captcha_code'))) {
            //	captcha_close();
            if (!count($errors)) {
                $id = core::$user->register(request_str('email'), request_str('password'));
                core::$sql->update(array('language_id' => core::$sql->i(request_int('language_id'))), DB . 'user', 'id=' . core::$sql->i($id));
                /*
                			        switch (request_int('language_id')) {
                			        	case 1: mail('*****@*****.**', 'subscribe gisconf '.request_str('email'), '*password: Oov4eeph', 'From: news@gisconf.ru'); break;
                			        	case 2: mail('*****@*****.**', 'subscribe gisconf-en '.request_str('email'), '*password: Oov4eeph', 'From: news-en@gisconf.ru'); break;
                			        }
                */
                go(core::$config['http_home'] . 'u' . $id . '/');
            }
            // }
            // else
            //	$errors []= 'Неверный код подтверждения';
        }
        $page = new PageCommon(s('Регистрация'));
        $html .= $page->start();
        $html .= '<div class="row"><div class="col-md-offset-4 col-md-4"><h2>' . s('Регистрация') . '</h2>';
        if (count($errors)) {
            $html .= '<div class="alert alert-danger"><p>' . escape($errors[0]) . '</p></div>';
        }
        $form = new Form('register', false, 'post');
        $html .= '<div class="well">' . $form->start() . $form->addVariable('is_posted', 1) . $form->addString('email', s('E-mail (будет использоваться для входа)'), $is_posted ? request_str('email') : '', array('is_required' => true)) . $form->addPassword('password', s('Пароль'), '', array('is_required' => true)) . $form->addPassword('password2', s('Подтверждение пароля'), '', array('is_required' => true)) . $form->addSelect('language_id', s('Язык'), $is_posted ? request_str('language_id') : (core::$config['current_language'] == 'ru' ? 1 : (core::$config['current_language'] == 'en' ? 2 : 0)), array('is_required' => true, 'data' => array(array('id' => 0, 'title' => '—'), array('id' => 1, 'title' => s('Русский')), array('id' => 2, 'title' => s('English')), array('id' => 3, 'title' => s('Polski'))))) . $form->submit(s('Зарегистрироваться')) . '</div>';
        $html .= '<ul>
				<li><a href="' . core::$config['http_home'] . 'login/">' . s('Вход для зарегистрированных') . '</a></li>
				<li><a href="' . core::$config['http_home'] . 'lost_password/">' . s('Забыли пароль?') . '</a></li>
			</ul>';
        $html .= '<script> $(document).ready(function() { $("#' . $jump_to . '").focus(); }); </script>';
        $html .= '</div></div>';
        $html .= $page->stop();
        return $html;
    }
Example #7
0
// group Personal data
$form->addGroup('Personal data');
$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 %d to %d', array(10, 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:');
$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>';
Example #8
0
 public function echoFolderEdit()
 {
     $success = true;
     $name;
     $id;
     if ($this->page_type == 'edit') {
         $sth = $this->db->prepare("SELECT `name` " . 'FROM `folders` WHERE `id`=?');
         $sth->execute(array($this->id));
         if ($row = $sth->fetch()) {
             $id = $this->id;
             $name = $row['name'];
         } else {
             $success = false;
         }
     }
     if ($success) {
         $form = new Form('folder');
         $form->addText('Folder name:', 'name', true, $name);
         $form->addHidden('id', $id);
         $form->addHidden('folder_id', $this->parent_folder_id);
         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, $this->id);
             if (count($move_arr) > 1) {
                 //$form->addHeading('Move');
                 $form->addSelect('Move to:', 'move', $move_arr);
             }
             $form->addDelete();
         }
         $form->echoForm();
     }
 }
Example #9
0
 public function echoPhone()
 {
     $phone;
     $dscr;
     $primary = 1;
     $type;
     $success = true;
     if ($this->contact_item_id) {
         $sth = $this->db->prepare("SELECT `type`,`primary`,`phone`,`dscr` " . 'FROM `con_phones` ' . 'WHERE `con_phones`.`id`=?');
         $sth->execute(array($this->contact_item_id));
         if ($row = $sth->fetch()) {
             $type = $row['type'];
             $phone = $row['phone'];
             $type = $row['type'];
             $dscr = $row['dscr'];
             $primary = $row['primary'];
         } else {
             $success = false;
         }
     }
     if ($success) {
         $form = new Form('phone');
         $form->addSelect('', 'type', array('Cell' => 'Cell', 'Home' => 'Home', 'Work' => 'Work', 'Fax' => 'Fax', 'Other' => 'Other'), $type);
         $form->addText('Phone:', 'phone', true, $phone, 'maxlength="20"');
         $form->addText('Description:', 'dscr', false, $dscr, 'maxlength="255"');
         $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 #10
0
 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();
     }
 }
Example #11
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 #12
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", $pageEntity);
$form->addSection("Page Management");
$form->addText("title", "Titolo", 60);
$form->addSelect("icon", "Icon", "Birra:icon-beer,Campanella:icon-bell,Segnato:icon-bookmark-empty,Altoparlante:icon-bullhorn,Bersaglio:icon-bullseye,Agenda:icon-calendar-empty,Fotocamera:icon-camera,Coffee:icon-coffee,Credit-card:icon-credit-card,Busta:icon-envelope-alt,Esclamazione:icon-exclamation,Video:icon-facetime-video,Film:icon-film,Bandiera:icon-flag-alt,Food:icon-food,Bicchiere:icon-glass,Globo:icon-globe,Love:icon-heart,Info:icon-info-sign,Laptop:icon-laptop,Lampadina:icon-lightbulb,Allright:icon-ok,Allright 2:icon-thumbs-up,Picture:icon-picture,Aeroplano:icon-plane,Smile:icon-smile,Star:icon-star-empty,Time:icon-time,Vittoria:icon-trophy,Ombrello:icon-umbrella");
$form->addEditor("description", "Message", 10, 50);
$form->addText("subtitle", "Sottotitolo", 60);
$form->addSelectFromReference2($sectionEntity, "section", "Sezione");
$form->addSelectFromReference2($newsCatEntity, "id_newscat", "News Category");
$form->addHierarchicalPosition("position", "Page Order", "title", "section");
$form->addEditor("body", "Content", 20, 50);
$form->addFile("foto", "Foto");
$form->addText("link", "Link", 60);
$form->addSelectFromReference2($menuEntity, "menu", "Menu");
if (!isset($_REQUEST['action'])) {
    $_REQUEST['action'] = "edit";
}
switch ($_REQUEST['action']) {
    case "add":
        $main->setContent("body", $form->addItem());
        break;
    case "edit":
        if ($_REQUEST['mode'] == "ajax") {
            echo $form->editItem();
        } else {