function initialize($entity = null, $options = null)
 {
     $date = new Date('date');
     $date->setLabel('Input Date');
     $date->setFilters(array('striptags', 'string'));
     $date->setDefault(date('Y-m-d'));
     $date->addValidators(array(new PresenceOf(array('message' => 'Date is required'))));
     $this->add($date);
     $start_time = new Text('start_hour');
     $start_time->setLabel('Input Start Hour');
     $start_time->setFilters(array('striptags', 'string'));
     $start_time->addValidators(array(new PresenceOf(array('message' => 'Start Time is required'))));
     $this->add($start_time);
     $finish_time = new Text('finish_hour');
     $finish_time->setLabel('Input Finish Hour');
     $finish_time->setFilters(array('striptags', 'string'));
     $finish_time->addValidators(array(new PresenceOf(array('message' => 'Finish Time is required'))));
     $this->add($finish_time);
     $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $systemId->setLabel('Select System');
     $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required'))));
     if ($entity) {
         $systemId->setDefault(array($entity->system_id));
     }
     $this->add($systemId);
     $description = new TextArea('description');
     $description->setLabel('Input Description');
     $description->addValidators(array(new PresenceOf(array('message' => 'Description is required'))));
     $this->add($description);
     $hidden = new Hidden('id');
     if ($entity) {
         $hidden->setDefault(array($entity->id));
     }
     $this->add($hidden);
 }
 public function initialize()
 {
     $type = new Radio('type', ['1' => '单选/多选', '3' => '判断']);
     $type->setLabel('题目类型');
     $type->addValidators([new PresenceOf(['message' => '题目类型必选'])]);
     $this->add($type);
     $question = new TextArea('question');
     $question->setLabel('题目');
     $question->addValidators([new PresenceOf(['message' => '题目内容必填'])]);
     $this->add($question);
 }
Esempio n. 3
0
 public function initialize($entity = null, $options = array())
 {
     $name = new Text('name', array('placeholder' => 'Name'));
     $name->setLabel('Name');
     $name->addValidators(array(new PresenceOf(array('message' => 'Please enter your name')), new StringLength(array('max' => 50, 'min' => 2, 'messageMaximum' => 'Name must have at most 50 characters', 'messageMinimum' => 'Name must have at least 2 characters'))));
     $this->add($name);
     $description = new TextArea('description', array('placeholder' => 'Description'));
     $description->setLabel('Description');
     $description->addValidators(array(new PresenceOf(array('message' => 'Please enter your description')), new StringLength(array('max' => 1000, 'min' => 5, 'messageMaximum' => 'Description must have at most 1000 characters', 'messageMinimum' => 'Name must have at least 5 characters'))));
     $this->add($description);
 }
 function initialize($entity = null, $options = null)
 {
     $name = new Text('name');
     $name->setLabel('Input Module');
     $name->setFilters(array('striptags', 'string'));
     $name->addValidators(array(new PresenceOf(array('message' => 'Name is required'))));
     $this->add($name);
     $description = new TextArea('description');
     $description->setLabel('Input Description');
     $description->addValidators(array(new PresenceOf(array('message' => 'Description is required'))));
     $this->add($description);
 }
 public function initialize($entity = null, $options = null)
 {
     // In edition the id is hidden
     if (isset($options['edit']) && $options['edit']) {
         $uid = new Hidden('uid');
     } else {
         $uid = new Text('uid');
     }
     $this->add($uid);
     $title = new Text('title', array());
     $title->addValidators(array(new PresenceOf(array('message' => 'The name is required'))));
     $this->add($title);
     $sourcecode = new TextArea('sourcecode', array());
     $sourcecode->addValidators(array(new PresenceOf(array('message' => 'The sourcecode is required'))));
     $this->add($sourcecode);
     $this->add(new Select('templatetype', array('0' => ControllerBase::translate('templateTypeMail'), '1' => ControllerBase::translate('templateTypeContent'))));
 }
Esempio n. 6
0
 public function initialize()
 {
     // phone
     $phone = new Text('phone');
     $phone->setLabel('电话');
     $phone->setFilters(array('striptags', 'string'));
     $phone->addValidators(array(new PresenceOf(array('message' => 'phone is required'))));
     $this->add($phone);
     // Email
     $email = new Text('email');
     $email->setLabel('邮件');
     $email->setFilters('email');
     $this->add($email);
     $message = new TextArea('msg');
     $message->setLabel('建议');
     $message->setFilters(array('striptags', 'string'));
     $message->addValidators(array(new PresenceOf(array('message' => 'message is required'))));
     $this->add($message);
 }
Esempio n. 7
0
 public function initialize($entity = null, $options = null)
 {
     // Name
     $name = new Text('name');
     $name->setLabel('Your Name');
     $name->setFilters(array('striptags', 'string'));
     $name->addValidators(array(new PresenceOf(array('message' => 'Name is required'))));
     $this->add($name);
     // Email
     $email = new Text('email');
     $email->setLabel('E-Mail');
     $email->setFilters('email');
     $email->addValidators(array(new PresenceOf(array('message' => 'E-mail is required')), new Email(array('message' => 'E-mail is not valid'))));
     $this->add($email);
     $comments = new TextArea('comments');
     $comments->setLabel('Comments');
     $comments->setFilters(array('striptags', 'string'));
     $comments->addValidators(array(new PresenceOf(array('message' => 'Comments is required'))));
     $this->add($comments);
 }
Esempio n. 8
0
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
     }
     //Firstname
     $firstName = new Text('firstname', ['placeholder' => t('Firstname'), 'required' => 'true', 'autofocus' => 'true']);
     $firstName->addValidators([new PresenceOf(['message' => t('Firstname is required.')])]);
     $this->add($firstName);
     //Lastname
     $lastName = new Text('lastname', ['placeholder' => 'Lastname', 'required' => 'true', 'autofocus' => 'true']);
     $lastName->addValidators([new PresenceOf(['message' => 'Lastname is required.'])]);
     $this->add($lastName);
     //Username
     $username = new Text('username', ['placeholder' => t('Username'), 'required' => 'true']);
     $username->addValidators([new PresenceOf(['message' => t('Username is required.')])]);
     $this->add($username);
     //@TODO : remove this when they fix radio button bug in Phalcon
     if (!empty($entity) && $entity->getGender() == Users::GENDER_MALE || $this->request->getPost('gender') == Users::GENDER_MALE) {
         $this->add(new Radio('genderMale', ['value' => Users::GENDER_MALE, 'checked' => 'checked', 'name' => 'gender', 'label' => 'Male']));
     } else {
         $this->add(new Radio('genderMale', ['value' => Users::GENDER_MALE, 'name' => 'gender', 'label' => 'Male']));
     }
     if (!empty($entity) && $entity->getGender() == Users::GENDER_FEMALE || $this->request->getPost('gender') == Users::GENDER_FEMALE) {
         $this->add(new Radio('genderFemale', ['value' => Users::GENDER_FEMALE, 'checked' => 'checked', 'name' => 'gender', 'label' => 'Female']));
     } else {
         $this->add(new Radio('genderFemale', ['value' => Users::GENDER_FEMALE, 'name' => 'gender']));
     }
     //Phannook weekly digest
     if (!empty($entity) && $entity->getDigest() == Users::DIGEST_YES || $this->request->getPost('digestYes') == Users::DIGEST_YES) {
         $this->add(new Radio('digestYes', ['value' => Users::DIGEST_YES, 'checked' => 'checked', 'name' => 'digest']));
     } else {
         $this->add(new Radio('digestYes', ['value' => Users::DIGEST_YES, 'name' => 'digest']));
     }
     if (!empty($entity) && $entity->getDigest() == Users::DIGEST_NO || $this->request->getPost('digest') == Users::DIGEST_NO) {
         $this->add(new Radio('digestNo', ['value' => Users::DIGEST_NO, 'checked' => 'checked', 'name' => 'digest']));
     } else {
         $this->add(new Radio('digestNo', ['value' => Users::DIGEST_NO, 'name' => 'digest']));
     }
     //notification
     $this->add(new Select('notifications', [Users::NOTIFY_N => 'Never receive an e-mail notification', Users::NOTIFY_Y => 'Receive e-mail notifications from all new threads and comments', Users::NOTIFY_P => 'When someone replies to a discussion that I started or replied to']));
     //Email
     $email = new Text('email', ['placeholder' => 'Email', 'required' => 'true']);
     $email->addValidators([new PresenceOf(['message' => 'The e-mail is required']), new Email(['message' => 'The e-mail is not valid'])]);
     $this->add($email);
     //Bio
     $bio = new TextArea('bio', ['placeholder' => 'Please add Bio information of your', 'required' => true, 'class' => 'wmd-input', 'id' => 'wmd-input', 'rows' => 10]);
     $bio->addValidators([new PresenceOf(['message' => 'The bio is required'])]);
     $this->add($bio);
     $twitter = new Text('twitter', ['placeholder' => 'Please add twiter of your']);
     $this->add($twitter);
     $github = new Text('github', ['placeholder' => 'Please add github of your']);
     $this->add($github);
     //Phone
     // $phone = new Text('phone', [
     //     'placeholder' => 'Phone',
     //     'required' => 'true'
     // ]);
     // $phone->addValidators([
     //         new PresenceOf([
     //             'message' => 'Phone numer is required.'
     //         ]),
     //         new Phone(array(
     //             'message' => t('Phone number is invalid and it needs to be in format 0722000777')
     //         ))
     //     ]);
     // $this->add($phone);
     //birhtDate
     $birthDate = new Text('birthDate', ['placeholder' => 'yyyy-mm-dd']);
     $birthDate->addValidators([new BirthDate(array('message' => t('Birthdate is invalid.')))]);
     $this->add($birthDate);
     //$this->add(new File('avatar'));
     // CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => t('CSRF validation failed'))));
     $this->add($csrf);
     //Submit
     $this->add(new Submit('save', ['value' => 'Save', 'class' => 'btn btn-sm btn-info']));
     $this->add(new Submit('saveAvatar', ['value' => 'Change avatar', 'class' => 'btn btn-sm btn-info']));
 }
 function initialize($entity = null, $options = null)
 {
     $date = new Date('date_found');
     $date->setLabel('Input Date Found');
     $date->setFilters(array('striptags', 'string'));
     $this->add($date);
     /*====================== Number =====================*/
     $number = new Text('number');
     $number->setLabel('Input Number');
     $number->setFilters(array('striptags', 'string'));
     $number->addValidators(array(new PresenceOf(array('message' => 'Number is required'))));
     $this->add($number);
     /*====================== Solved =====================*/
     $isSolved = new Radio('is_solved', array('name' => 'is_solved', 'value' => '1'));
     $isSolved->setLabel('Is Solved');
     $isSolved->addValidators(array(new PresenceOf(array('message' => 'Is solved is required'))));
     $this->add($isSolved);
     $isSolved2 = new Radio('is_solved2', array('name' => 'is_solved', 'value' => '0', 'checked' => TRUE));
     $isSolved2->setLabel('Is Solved2');
     $isSolved2->addValidators(array(new PresenceOf(array('message' => 'Is solved is required'))));
     $this->add($isSolved2);
     $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $systemId->setLabel('Select System');
     $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required'))));
     if ($entity) {
         $systemId->setDefault(array($entity->system_id));
     }
     $this->add($systemId);
     $modulesId = new Select('modules_id', Modules::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $modulesId->setLabel('Select Modules');
     $modulesId->addValidators(array(new PresenceOf(array('message' => 'Modules is required'))));
     if ($entity) {
         $modulesId->setDefault(array($entity->modules_id));
     }
     $this->add($modulesId);
     /*===== Bug =============*/
     $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $systemId->setLabel('Select System');
     $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required'))));
     if ($entity) {
         $systemId->setDefault(array($entity->system_id));
     }
     $this->add($systemId);
     $description = new TextArea('description');
     $description->setLabel('Input Description');
     $description->addValidators(array(new PresenceOf(array('message' => 'Description is required'))));
     $this->add($description);
     $hidden = new Hidden('id');
     if ($entity) {
         $hidden->setDefault(array($entity->id));
     }
     $this->add($hidden);
 }