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')))); }
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) { // 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')); $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) { // 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')])); }
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')))); }