Beispiel #1
0
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
     }
     //title
     $title = new Text('title', array('placeholder' => t('title'), 'class' => 'form-control', 'required' => true));
     $title->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($title);
     $tags = new Hidden('tags', array('required' => true));
     $tags->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($tags);
     //content
     $content = new Textarea('content', array('placeholder' => t('Please be sure to answer the question. Provide details and share your research!'), 'class' => 'wmd-input', 'id' => 'wmd-input', 'required' => true, 'rows' => 10));
     $content->addValidator(new PresenceOf(array('message' => t('content is required.'))));
     $this->add($content);
     $this->add(new Hidden('object'));
     // To compare the post is question or tip
     $this->add(new Hidden('type'));
     // CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed')));
     $this->add($csrf);
     $this->add(new Submit('save', array('class' => 'btn btn-sm btn-success', 'value' => t('Submit Post'))));
 }
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
     }
     //title
     $title = new Text('title', array('placeholder' => t('title'), 'class' => 'form-control', 'required' => true));
     $title->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($title);
     //title
     $link = new Text('link', array('class' => 'form-control', 'required' => true));
     $link->addValidator(new PresenceOf(array('message' => t('The link is required.'))));
     $this->add($link);
     //content
     $content = new Textarea('content', array('placeholder' => t('Adding information for link your submit!'), 'class' => 'wmd-input', 'id' => 'wmd-input', 'required' => true, 'rows' => 10));
     $content->addValidator(new PresenceOf(array('message' => t('content is required.'))));
     $this->add($content);
     $this->add(new Hidden('object'));
     // To compare the post is question or tip
     $this->add(new Hidden('type'));
     // CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed')));
     $this->add($csrf);
     $this->add(new Submit('save', array('class' => 'btn btn-sm btn-success', 'value' => t('Submit Link'))));
 }
Beispiel #3
0
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
     }
     //title
     $title = new Text('title', array('placeholder' => t('Title'), 'class' => 'form-control', 'required' => true));
     $title->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($title);
     // In edit page the id is hidden
     if (!empty($entity)) {
         $checked = null;
         $this->add(new Radio('locked', ['value' => 'Y', 'checked' => $checked, 'name' => 'locked']));
         if ($entity->getLocked() == 'N') {
             $checked = 'checked';
         }
         $this->add(new Radio('unLocked', ['value' => 'N', 'checked' => $checked, 'name' => 'locked']));
     } else {
         $this->add(new Radio('locked', ['value' => 'Y', 'name' => 'locked']));
         $this->add(new Radio('unLocked', ['value' => 'N', 'name' => 'locked']));
     }
     //content
     $content = new Textarea('content', array('placeholder' => t('Please be sure to answer the question. Provide details and share your research!'), 'class' => 'wmd-input', 'id' => 'wmd-input', 'required' => true, 'rows' => 10));
     $content->addValidator(new PresenceOf(array('message' => t('content is required.'))));
     $this->add($content);
     $this->add(new Hidden('object'));
     // To compare the post is question or tip
     $this->add(new Hidden('type'));
     // CSRF
     $csrf = new Hidden('csrf');
     $this->add($csrf);
     $this->add(new Submit('save', array('class' => 'btn btn-sm btn-success', 'value' => t('Submit Post'))));
 }
 public function initialize($entity = null, $options = null)
 {
     $country = new Select('countryid', Country::find(), array('using' => array('id', 'country'), 'useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione un País')));
     $country->setLabel('País');
     $this->add($country);
     if (isset($entity)) {
         if ($entity->getCountryid()) {
             $state = new Select('stateid', State::find(array("columns" => array("id,state"), "conditions" => "countryid =:countryid:", "bind" => array("countryid" => $entity->countryid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Estado'), 'using' => array('id', 'state')));
             $state->setLabel('Estado');
             $this->add($state);
             $city = new Select('cityid', City::find(array("columns" => array("id,city"), "conditions" => "countryid =:countryid: AND stateid =:stateid: ", "bind" => array("countryid" => $entity->countryid, "stateid" => $entity->stateid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione una ciudad'), 'using' => array('id', 'city')));
             $city->setLabel('Ciudad');
             $this->add($city);
             $township = new Select('townshipid', Township::find(array("columns" => array("id,township"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Sector'), 'using' => array('id', 'township')));
             $township->setLabel('Sector');
             $this->add($township);
             $neighborhood = new Select('neighborhoodid', Neighborhood::find(array("columns" => array("id,neighborhood"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Barrio'), 'using' => array('id', 'neighborhood')));
             $neighborhood->setLabel('Barrio');
             $this->add($neighborhood);
         } else {
             $this->set_empty_values();
         }
     } else {
         $this->set_empty_values();
     }
     $address = new Textarea('address', array("maxlength" => "400"));
     $address->setLabel('Dirección');
     $this->add($address);
     $description = new Textarea('description', array("maxlength" => "100"));
     $description->setLabel('Descripción');
     $this->add($description);
 }
Beispiel #5
0
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
         $this->tagsId = $entity->getTagsId();
     }
     //title
     $title = new Text('title', array('placeholder' => t('Title'), 'class' => 'form-control', 'required' => true));
     $title->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($title);
     // In edit page the id is hidden
     if (!empty($entity)) {
         $checked = null;
         $this->add(new Radio('locked', ['value' => 'Y', 'checked' => $checked, 'name' => 'locked']));
         if ($entity->getLocked() == 'N') {
             $checked = 'checked';
         }
         $this->add(new Radio('unLocked', ['value' => 'N', 'checked' => $checked, 'name' => 'locked']));
     } else {
         $this->add(new Radio('locked', ['value' => 'Y', 'name' => 'locked']));
         $this->add(new Radio('unLocked', ['value' => 'N', 'name' => 'locked', 'checked' => '']));
     }
     //content
     $content = new Textarea('content', ['data-provide' => 'markdown', 'data-iconlibrary' => 'fa', 'required' => true, 'rows' => 15]);
     $content->addValidator(new PresenceOf(array('message' => t('content is required.'))));
     $this->add($content);
     $excerpt = new Textarea('excerpt', ['rows' => 4]);
     $this->add($excerpt);
     $tags = new Hidden('tags', ['placeholder' => t('Tags'), 'class' => 'form-control']);
     $this->add($tags);
     $this->add(new Hidden('object'));
     // To compare the post is question or tip
     $this->add(new Hidden('type'));
     // CSRF
     $csrf = new Hidden('csrf');
     $this->add($csrf);
     //
     $thumbnail = new Text('thumbnail', ['class' => 'form-control']);
     $this->add($thumbnail);
     //Type
     $type = new Select('type', [Posts::POST_BLOG => 'Blog', Posts::POST_PAGE => 'Page', Posts::POST_QUESTIONS => 'Questions', Posts::POST_HACKERNEWS => 'Hackernew'], ['useEmpty' => true, 'emptyText' => 'Please, choose one...', 'class' => 'form-control', 'required' => true]);
     $this->add($type);
     $this->add(new Submit('save', array('class' => 'btn btn-sm btn-success pull-right', 'value' => t('Publish Post'))));
     $this->add(new Submit('saveDraft', ['class' => 'btn btn-sm btn-primary pull-left', 'value' => t('Save Draft')]));
 }
	public function initialize($entity = null, $options = null)
    {
       	$created = new Date('created');
		$created->setLabel('Дата');
		$this->add($created); 	
		
    	$sum = new Numeric('sum');
		$sum->setLabel('Сумма');
		$this->add($sum);
		
    	$categoryID = new Hidden('categoryID');
		$this->add($categoryID);
		
    	$text = new Textarea('text');
		$text->setLabel('Описание');
		$this->add($text);				
	}
Beispiel #7
0
 /**
  * Form configuration
  */
 public function initialize($entity = null, $options = null)
 {
     $t = $this->getDI()->get('translate');
     // In edition the id is hidden
     if (isset($options['edit']) && $options['edit']) {
         $id = new Hidden('id');
     } else {
         $id = new Text('id');
     }
     $id->setLabel($t->gettext('Id'));
     $this->add($id);
     // Name field
     $name = new Text('name', ['placeholder' => $t->gettext('Name')]);
     $name->setLabel($t->gettext('Name'));
     $name->addValidators([new PresenceOf(['message' => $t->gettext('Name is required')])]);
     $this->add($name);
     // Email field
     $email = new Text('email', ['placeholder' => $t->gettext('Email')]);
     $email->setLabel($t->gettext('Email'));
     $email->addValidators([new PresenceOf(['message' => $t->gettext('Email is required')]), new Email(['message' => $t->gettext('Email is not valid')])]);
     $this->add($email);
     // rolesId field
     $roles = Roles::find(['active = :active:', 'bind' => ['active' => 'Y']]);
     $role = new Select('rolesId', $roles, ['using' => ['id', 'name'], 'useEmpty' => true, 'emptyText' => '...', 'emptyValue' => '']);
     $role->setLabel($t->gettext('Role'));
     $role->addValidators([new PresenceOf(['message' => $t->gettext('The user role must be set.')])]);
     $this->add($role);
     // active field
     $active = new Select('active', ['N' => $t->gettext('No'), 'Y' => $t->gettext('Yes')]);
     $active->setLabel($t->gettext('Active'));
     $this->add($active);
     // banned field
     $banned = new Select('banned', ['Y' => $t->gettext('Yes'), 'N' => $t->gettext('No')]);
     $banned->setLabel($t->gettext('Banned'));
     $this->add($banned);
     // emailActivationMsg field
     $emailExtraMsg = new Textarea('emailActivationMsg', ['placeholder' => $t->gettext('Add text to send confirmation email.')]);
     $emailExtraMsg->setLabel($t->gettext('Send activation email'));
     $this->add($emailExtraMsg);
     // Submit
     $submit = new Submit('submit', ['value' => $t->gettext('Save')]);
     $this->add($submit);
 }
Beispiel #8
0
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
     }
     //title
     $title = new Text('title', array('placeholder' => t('Title'), 'class' => 'form-control', 'required' => true));
     $title->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($title);
     // In edit page the id is hidden
     if (!empty($entity)) {
         $checked = null;
         $this->add(new Radio('locked', ['value' => 'Y', 'checked' => $checked, 'name' => 'locked']));
         if ($entity->getLocked() == 'N') {
             $checked = 'checked';
         }
         $this->add(new Radio('unLocked', ['value' => 'N', 'checked' => $checked, 'name' => 'locked']));
     } else {
         $this->add(new Radio('locked', ['value' => 'Y', 'name' => 'locked']));
         $this->add(new Radio('unLocked', ['value' => 'N', 'name' => 'locked', 'checked' => '']));
     }
     //content
     $content = new Textarea('content', ['data-provide' => 'markdown', 'data-iconlibrary' => 'fa', 'required' => true, 'rows' => 15]);
     $content->addValidator(new PresenceOf(array('message' => t('content is required.'))));
     $this->add($content);
     $excerpt = new Textarea('excerpt', ['rows' => 4]);
     $this->add($excerpt);
     $tags = new Hidden('tags', ['placeholder' => t('Tags'), 'class' => 'form-control']);
     $this->add($tags);
     $this->add(new Hidden('object'));
     // To compare the post is question or tip
     $this->add(new Hidden('type'));
     // CSRF
     $csrf = new Hidden('csrf');
     $this->add($csrf);
     $this->add(new Submit('save', array('class' => 'btn btn-sm btn-success pull-right', 'value' => t('Submit Post'))));
     $this->add(new Submit('saveDraft', ['class' => 'btn btn-sm btn-primary pull-left', 'value' => t('Save Draft')]));
 }
Beispiel #9
0
 public function initialize($entity = null)
 {
     // In edit page the id is hidden
     if (!is_null($entity)) {
         $this->add(new Hidden('id'));
         $this->tagsId = $entity->getTagsId();
     }
     //title
     $title = new Text('title', array('placeholder' => t('title'), 'class' => 'form-control', 'required' => true));
     $title->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($title);
     $tags = new Hidden('tags', array('required' => true));
     $tags->addValidator(new PresenceOf(array('message' => t('The title is required.'))));
     $this->add($tags);
     //content
     $content = new Textarea('content', array('placeholder' => t('Please be sure to answer the question. Provide details and share your research!'), 'id' => 'question-details', 'required' => true, 'rows' => 8, 'cols' => 100, 'data-provide' => 'markdown', 'data-iconlibrary' => 'fa', 'required' => true));
     $content->addValidator(new PresenceOf(array('message' => t('content is required.'))));
     $this->add($content);
     $this->add(new Hidden('object'));
     // To compare the post is question or tip
     $this->add(new Hidden('type'));
     $this->add(new Submit('save', array('class' => 'button color small submit', 'id' => 'publish-question', 'value' => t('Publish Your Question'))));
 }