本文整理汇总了PHP中Engine_Form类的典型用法代码示例。如果您正苦于以下问题:PHP Engine_Form类的具体用法?PHP Engine_Form怎么用?PHP Engine_Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Engine_Form类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
//parent::init();
$this->addDecorators(array('FormElements'));
$fields = Engine_Api::_()->getApi('core', 'fields')->getFieldsMeta($this->_type);
foreach ($fields as $field) {
if (!$field->search || !$field->alias) {
continue;
}
$key = $field->alias;
// Hack for birthday type fields
$params = $field->getElementParams($this->_type, array('required' => false));
// Range type fields
if ($field->type == 'date' || $field->type == 'birthdate' || $field->type == 'float') {
$subform = new Engine_Form(array('description' => $params['options']['label'], 'elementsBelongTo' => $key, 'decorators' => array('FormElements', array('Description', array('placement' => 'PREPEND', 'tag' => 'label', 'class' => 'form-label')), array('HtmlTag', array('tag' => 'div', 'class' => 'integer_field form-wrapper integer_field_unselected', 'id' => 'integer-wrapper')))));
//Engine_Form::enableForm($subform);
unset($params['options']['label']);
$params['options']['decorators'] = array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'form-element')));
$subform->addElement($params['type'], 'min', $params['options']);
$subform->addElement($params['type'], 'max', $params['options']);
$this->addSubForm($subform, $key);
} else {
$this->addElement($params['type'], $key, $params['options']);
}
$element = $this->getElement($key);
}
$this->addElement('Button', 'done', array('label' => 'Search', 'type' => 'submit'));
}
示例2: init
public function init()
{
// Set form attributes
$this->setTitle('Create Advertisement');
$this->setDescription('Follow this guide to design and create a new advertisement.');
$this->setAttrib('id', 'form-upload');
$this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
// Title
$this->addElement('Text', 'name', array('label' => 'Advertisement Name', 'allowEmpty' => false, 'required' => true, 'validators' => array(array('NotEmpty', true), array('StringLength', false, array(1, 64))), 'filters' => array('StripTags', new Engine_Filter_Censor(), new Engine_Filter_EnableLinks())));
$this->addElement('Radio', 'media_type', array('id' => 'mediatype', 'label' => 'Advertisement Media', 'onchange' => "updateTextFields(this)", 'multiOptions' => array("0" => "Upload Banner Image", "1" => "Insert Banner HTML"), 'description' => 'CORE_FORM_ADMIN_ADS_AD_MEDIATYPE_DESCRIPTION'));
// $this->media->getDecorator('Description')->setOption('placement', 'append');
// Init file
$fancyUpload = new Engine_Form_Element_FancyUpload('file');
$fancyUpload->clearDecorators()->addDecorator('FormFancyUpload')->addDecorator('viewScript', array('viewScript' => '_FancyUpload.tpl', 'placement' => ''));
Engine_Form::addDefaultDecorators($fancyUpload);
$fancyUpload->setLabel("Upload Banner Image");
$this->addElement($fancyUpload);
$this->addElement('Hidden', 'photo_id');
$this->addDisplayGroup(array('file'), 'upload_image');
$upload_image_group = $this->getDisplayGroup('upload_image');
$this->addElement('Textarea', 'html_code', array('label' => 'HTML Code'));
// Buttons
$this->addElement('Button', 'preview_html', array('label' => 'Preview', 'ignore' => true, 'onclick' => 'javascript:preview();', 'decorators' => array('ViewHelper')));
$this->addDisplayGroup(array('html_code', 'preview_html'), 'html_field');
$html_code_group = $this->getDisplayGroup('html_code');
// init submit
$this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
}
示例3: init
public function init()
{
$this->setTitle('Compose Message');
$this->setDescription('Create your new message with the form below. Your message can be addressed to up to 10 recipients.')->setAttrib('id', 'notice_compose');
$user_level = Engine_Api::_()->user()->getViewer()->level_id;
// init to
$this->addElement('Text', 'to', array('label' => 'Send To', 'autocomplete' => 'off'));
Engine_Form::addDefaultDecorators($this->to);
// Init to Values
$this->addElement('Hidden', 'toValues', array('label' => 'Send To', 'required' => true, 'allowEmpty' => false, 'order' => 2, 'validators' => array('NotEmpty'), 'filters' => array('HtmlEntities')));
Engine_Form::addDefaultDecorators($this->toValues);
// init title
$this->addElement('Text', 'title', array('label' => 'Subject', 'order' => 4, 'filters' => array(new Engine_Filter_Censor(), new Engine_Filter_HtmlSpecialChars())));
// init body - editor
$editor = Engine_Api::_()->getDbtable('permissions', 'authorization')->getAllowed('messages', $user_level, 'editor');
if ($editor == 'editor') {
$this->addElement('TinyMce', 'body', array('disableLoadDefaultDecorators' => true, 'order' => 5, 'required' => true, 'editorOptions' => array('bbcode' => true, 'html' => true), 'allowEmpty' => false, 'decorators' => array('ViewHelper', 'Label', array('HtmlTag', array('style' => 'display: block;'))), 'filters' => array(new Engine_Filter_HtmlSpecialChars(), new Engine_Filter_Censor(), new Engine_Filter_EnableLinks())));
} else {
// init body - plain text
$this->addElement('Textarea', 'body', array('label' => 'Message', 'order' => 5, 'required' => true, 'allowEmpty' => false, 'filters' => array(new Engine_Filter_HtmlSpecialChars(), new Engine_Filter_Censor(), new Engine_Filter_EnableLinks())));
}
$this->addAdditionalElements();
$this->loadDefaultDecorators();
$this->getDecorator('Description')->setOption('escape', false);
// init submit
$this->addElement('Button', 'submit', array('label' => 'Send Message', 'order' => 7, 'type' => 'submit', 'ignore' => true));
}
示例4: init
public function init()
{
$this->setTitle('Compose Message');
$this->setDescription('Create your new message with the form below. Your message can be addressed to up to 10 recipients.')->setAttrib('id', 'messages_compose');
$user_level = Engine_Api::_()->user()->getViewer()->level_id;
// init to
$this->addElement('Text', 'to', array('label' => 'Send To', 'autocomplete' => 'off'));
Engine_Form::addDefaultDecorators($this->to);
// Init to Values
$this->addElement('Hidden', 'toValues', array('label' => 'Send To', 'required' => true, 'allowEmpty' => false, 'order' => 2, 'validators' => array('NotEmpty'), 'filters' => array('HtmlEntities')));
Engine_Form::addDefaultDecorators($this->toValues);
// init title
$this->addElement('Text', 'title', array('label' => 'Subject', 'order' => 3, 'filters' => array(new Engine_Filter_Censor(), new Engine_Filter_HtmlSpecialChars())));
// init body - editor
$editor = Engine_Api::_()->getDbtable('permissions', 'authorization')->getAllowed('messages', $user_level, 'editor');
if ($editor == 'editor') {
$editorOptions = array('bbcode' => true, 'html' => true);
if (Engine_Api::_()->authorization()->isAllowed('album', $user, 'create')) {
$upload_url = Zend_Controller_Front::getInstance()->getRouter()->assemble(array('action' => 'upload-photo'), 'messages_general', true);
}
if (!empty($upload_url)) {
$editorOptions['upload_url'] = $upload_url;
$editorOptions['plugins'] = array('table', 'fullscreen', 'media', 'preview', 'paste', 'code', 'image', 'textcolor', 'jbimages', 'link');
$editorOptions['toolbar1'] = array('undo', 'redo', 'removeformat', 'pastetext', '|', 'code', 'media', 'image', 'jbimages', 'link', 'fullscreen', 'preview');
}
$this->addElement('TinyMce', 'body', array('disableLoadDefaultDecorators' => true, 'order' => 4, 'required' => true, 'editorOptions' => $editorOptions, 'allowEmpty' => false, 'decorators' => array('ViewHelper', 'Label', array('HtmlTag', array('style' => 'display: block;'))), 'filters' => array(new Engine_Filter_HtmlSpecialChars(), new Engine_Filter_Censor())));
} else {
// init body - plain text
$this->addElement('Textarea', 'body', array('label' => 'Message', 'order' => 4, 'required' => true, 'allowEmpty' => false, 'filters' => array(new Engine_Filter_HtmlSpecialChars(), new Engine_Filter_Censor(), new Engine_Filter_EnableLinks())));
}
// init submit
$this->addElement('Button', 'submit', array('label' => 'Send Message', 'order' => 5, 'type' => 'submit', 'ignore' => true));
}
示例5: init
public function init()
{
$this->setAttrib('enctype', 'multipart/form-data')->setAttrib('name', 'EditPhoto');
$this->addElement('Image', 'current', array('label' => 'Current Photo', 'ignore' => true, 'decorators' => array(array('ViewScript', array('viewScript' => '_formEditImage.tpl', 'class' => 'form element', 'testing' => 'testing')))));
Engine_Form::addDefaultDecorators($this->current);
$this->addElement('File', 'Filedata', array('label' => 'Choose New Photo', 'destination' => APPLICATION_PATH . '/public/temporary/', 'multiFile' => 1, 'validators' => array(array('Count', false, 1), array('Extension', false, 'jpg,jpeg,png,gif')), 'onchange' => 'javascript:uploadSignupPhoto();'));
$this->addElement('Hidden', 'coordinates', array('filters' => array('HtmlEntities')));
$this->addElement('Button', 'done', array('label' => 'Save Photo', 'type' => 'submit'));
}
示例6: init
public function init()
{
$this->setAttrib('enctype', 'multipart/form-data')->setAttrib('name', 'CropPhoto');
$this->addElement('Image', 'current', array('label' => 'Main Photo', 'ignore' => true, 'decorators' => array(array('ViewScript', array('viewScript' => '_formCropImage.tpl', 'class' => 'form element', 'testing' => 'testing')))));
Engine_Form::addDefaultDecorators($this->current);
$this->addElement('Hidden', 'coordinates', array('filters' => array('HtmlEntities')));
$this->addElement('Button', 'done', array('label' => 'Save Photo', 'type' => 'submit', 'onsubmit' => 'lassoEnd()', 'decorators' => array('ViewHelper')));
$this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'link' => true, 'prependText' => ' or ', 'href' => 'javascript:void(0)', 'onclick' => 'parent.Smoothbox.close()', 'class' => 'smoothbox', 'decorators' => array('ViewHelper')));
$this->addDisplayGroup(array('done', 'cancel'), 'buttons');
}
示例7: getAdditionalOptionsElement
public function getAdditionalOptionsElement()
{
$subform = new Zend_Form_SubForm(array('name' => 'extra', 'order' => 1000000, 'decorators' => array('FormElements')));
Engine_Form::enableForm($subform);
$subform->addElement('Checkbox', 'has_photo', array('label' => 'Only Members With Photos', 'decorators' => array('ViewHelper', array('Label', array('placement' => 'APPEND', 'tag' => 'label')), array('HtmlTag', array('tag' => 'li')))));
$subform->addElement('Checkbox', 'is_online', array('label' => 'Only Online Members', 'decorators' => array('ViewHelper', array('Label', array('placement' => 'APPEND', 'tag' => 'label')), array('HtmlTag', array('tag' => 'li')))));
$subform->addElement('Button', 'done', array('label' => 'Search', 'onclick' => 'javascript:searchMembers()', 'ignore' => true));
$this->addSubForm($subform, $subform->getName());
return $this;
}
示例8: loadDefaultDecorators
/**
* Load default decorators
*
* @return void
*/
public function loadDefaultDecorators()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
Engine_Form::addDefaultDecorators($this);
}
}
示例9: init
public function init()
{
$view = Zend_Registry::get('Zend_View');
$settings = Engine_Api::_()->getApi('settings', 'core');
$viewer = Engine_Api::_()->user()->getViewer();
$this->setTitle('Edit Feedback');
//Category
$this->addElement('Select', 'category_id', array('required' => true, 'allowEmpty' => false, 'label' => '*Category'));
//Custom field
$customFields = new Ynfeedback_Form_Feedback_Fields(array_merge(array('item' => $this->_item), $this->_formArgs));
$this->addSubForms(array('fields' => $customFields));
//Business name
$this->addElement('Text', 'title', array('label' => '*Feedback', 'allowEmpty' => false, 'required' => true, 'validators' => array(array('NotEmpty', true), array('StringLength', false, array(1, 100))), 'filters' => array('StripTags', new Engine_Filter_Censor())));
//description
$this->addElement('Textarea', 'description', array('label' => '*Description', 'allowEmpty' => false, 'required' => true, 'filters' => array(), 'validators' => array(array('NotEmpty', true))));
//Co-authors
$this->addElement('Text', 'to', array('label' => 'Co-authors', 'autocomplete' => 'off'));
Engine_Form::addDefaultDecorators($this->to);
// Init to Values
$this->addElement('Hidden', 'toValues', array('style' => 'margin-top:-5px', 'order' => 5, 'filters' => array('HtmlEntities')));
Engine_Form::addDefaultDecorators($this->toValues);
//Severity
$this->addElement('Select', 'severity', array('required' => true, 'allowEmpty' => false, 'label' => 'Severity'));
$tableSeverity = Engine_Api::_()->getDbTable('severities', 'ynfeedback');
$this->severity->addMultiOptions($tableSeverity->getSeverityArray());
// Privacy
$viewOptions = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('ynfeedback_idea', $viewer, 'auth_view');
$commentOptions = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('ynfeedback_idea', $viewer, 'auth_comment');
$availableLabels = array('everyone' => $view->translate('Everyone'), 'owner_network' => $view->translate('Friends and Networks'), 'owner_member_member' => $view->translate('Friends of Friends'), 'owner_member' => $view->translate('Friends Only'), 'owner' => $view->translate('Just Me'));
$viewOptions = array_intersect_key($availableLabels, array_flip($viewOptions));
$commentOptions = array_intersect_key($availableLabels, array_flip($commentOptions));
// View
if (!empty($viewOptions) && count($viewOptions) >= 1) {
// Make a hidden field
if (count($viewOptions) == 1) {
$this->addElement('hidden', 'auth_view', array('value' => key($viewOptions)));
// Make select box
} else {
$this->addElement('Select', 'auth_view', array('label' => 'Privacy', 'multiOptions' => $viewOptions, 'value' => key($viewOptions)));
}
}
// Comment
if (!empty($commentOptions) && count($commentOptions) >= 1) {
// Make a hidden field
if (count($commentOptions) == 1) {
$this->addElement('hidden', 'auth_comment', array('value' => key($commentOptions)));
// Make select box
} else {
$this->addElement('Select', 'auth_comment', array('label' => 'Comment Privacy', 'multiOptions' => $commentOptions, 'value' => key($commentOptions)));
}
}
$this->addElement('Button', 'submit_button', array('value' => 'submit_button', 'label' => 'Save Changes', 'onclick' => 'removeSubmit()', 'type' => 'submit', 'ignore' => true, 'decorators' => array('ViewHelper')));
$this->addElement('Cancel', 'cancel', array('label' => 'Cancel', 'link' => true, 'prependText' => ' or ', 'decorators' => array('ViewHelper')));
$this->addDisplayGroup(array('submit_button', 'cancel'), 'buttons', array('decorators' => array('FormElements', 'DivDivDivWrapper')));
}
示例10: loadDefaultDecorators
/**
* Load default decorators
*
* @return void
*/
public function loadDefaultDecorators()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->addDecorator('Tooltip')->addDecorator('Image');
Engine_Form::addDefaultDecorators($this);
}
}
示例11: init
public function init()
{
$this->setAttrib('enctype', 'multipart/form-data')->setAttrib('name', 'EditPhoto');
$this->addElement('Image', 'current', array('label' => 'Current Photo', 'ignore' => true, 'decorators' => array(array('ViewScript', array('viewScript' => '_formEditImage.tpl', 'class' => 'form element', 'testing' => 'testing')))));
Engine_Form::addDefaultDecorators($this->current);
$this->addElement('File', 'Filedata', array('label' => 'Choose New Photo', 'destination' => APPLICATION_PATH . '/public/temporary/', 'multiFile' => 1, 'validators' => array(array('Count', false, 1), array('Extension', false, 'jpg,jpeg,png,gif')), 'onchange' => 'javascript:uploadSignupPhoto();'));
$this->addElement('Hidden', 'coordinates', array('filters' => array('HtmlEntities')));
$this->addElement('Button', 'done', array('label' => 'Save Photo', 'type' => 'submit', 'decorators' => array('ViewHelper')));
$this->addElement('Cancel', 'remove', array('label' => 'remove photo', 'link' => true, 'prependText' => ' or ', 'href' => Zend_Controller_Front::getInstance()->getRouter()->assemble(array('action' => 'remove-photo')), 'onclick' => null, 'class' => 'smoothbox', 'decorators' => array('ViewHelper')));
$this->addDisplayGroup(array('done', 'remove'), 'buttons');
}
示例12: init
public function init()
{
$auth = Engine_Api::_()->authorization()->context;
$user = $this->getItem();
$this->setTitle('Privacy Settings')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
// Init blocklist
$this->addElement('Hidden', 'blockList', array('label' => 'Blocked Members', 'description' => 'Adding a person to your block list makes your profile (and all of your other content) unviewable to them. Any connections you have to the blocked person will be canceled.', 'order' => -1));
Engine_Form::addDefaultDecorators($this->blockList);
// Init search
$this->addElement('Checkbox', 'search', array('label' => 'Do not display me in searches, browsing members, or the "Online Members" list.', 'checkedValue' => 0, 'uncheckedValue' => 1));
$availableLabels = array('owner' => 'Only Me', 'member' => 'Only My Followers', 'network' => 'Followers & Networks', 'registered' => 'All Registered Members', 'everyone' => 'Everyone');
// Init profile view
$view_options = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('user', $user, 'auth_view');
$view_options = array_intersect_key($availableLabels, array_flip($view_options));
$this->addElement('Radio', 'privacy', array('label' => 'Profile Privacy', 'description' => 'Who can view your profile?', 'multiOptions' => $view_options));
foreach ($this->_roles as $role) {
if (1 === $auth->isAllowed($user, $role, 'view')) {
$this->privacy->setValue($role);
}
}
$availableLabelsComment = array('owner' => 'Only Me', 'member' => 'Only My Followers', 'network' => 'Followers & Networks', 'registered' => 'All Registered Members');
// Init profile comment
$comment_options = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('user', $user, 'auth_comment');
$comment_options = array_intersect_key($availableLabelsComment, array_flip($comment_options));
$this->addElement('Radio', 'comment', array('label' => 'Profile Posting Privacy', 'description' => 'Who can post on your profile?', 'multiOptions' => $comment_options));
foreach ($this->_roles as $role) {
if (1 === $auth->isAllowed($user, $role, 'comment')) {
$this->comment->setValue($role);
}
}
$this->addElement('Radio', 'private_contact', array('label' => 'Private Contact Information', 'description' => 'Who can view my private contact information?', 'multiOptions' => array(0 => 'Everyone', 1 => 'Followers & Professionals', 2 => 'Professionals Only')));
$availableLabels = array('owner' => 'Only Me', 'member' => 'Only My Followers', 'network' => 'Followers & Networks', 'registered' => 'All Registered Members');
// Init profile view
$get_notification_options = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('ynmember_user', $user, 'auth_get_notification');
$get_notification_options = array_intersect_key($availableLabels, array_flip($get_notification_options));
$this->addElement('Radio', 'get_notification_privacy', array('label' => 'Get Notification Privacy', 'description' => 'Who can get notification for some of my action? Actions: Create new items.
Join/attend Club/Event.
All actions on members (follow/rate member, etc...).
Like/comment an item.', 'multiOptions' => $get_notification_options));
foreach ($this->_roles as $role) {
if (1 === $auth->isAllowed($user, $role, 'get_notification')) {
$this->get_notification_privacy->setValue($role);
}
}
// Init publishtypes
if (Engine_Api::_()->getApi('settings', 'core')->getSetting('activity.publish', true)) {
$this->addElement('MultiCheckbox', 'publishTypes', array('label' => 'Recent Activity Privacy', 'description' => 'Which of the following things do you want to have published about you in the recent activity feed? Note that changing this setting will only affect future news feed items.'));
}
// Init submit
$this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
return $this;
}
示例13: init
public function init()
{
$this->setAttribs(array('id' => 'filter_form', 'class' => 'global_form_box'))->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
parent::init();
$this->addElement('Text', 'search', array('label' => 'Search Music:'));
$this->addElement('Select', 'sort', array('label' => 'Browse By:', 'multiOptions' => array('recent' => 'Most Recent', 'popular' => 'Most Popular')));
}
示例14: render
public function render(Zend_View_Interface $view = null)
{
if ($this->isEmailAntispamEnabled()) {
$this->{$this->_orgEmailFieldName}->setValue('');
}
return parent::render($view);
}
示例15: getValues
public function getValues()
{
$values = parent::getValues();
$address = trim($values['address']);
$keyword = trim($values['keyword']);
$zipcode = $values['zipcode'];
$values['keyword'] = $keyword;
$values['address'] = $address;
$values['address_pattern'] = "%%";
if ($keyword) {
if ($values['match']) {
$values['keyword_pattern'] = implode('|', array_map(array($this, 'boundWord'), preg_split('#\\s+#', $keyword)));
} else {
$values['keyword_partern'] = $this->boundWord(implode('|', preg_split('#\\s+#', $keyword)));
}
} else {
$values['keyword_pattern'] = '';
}
try {
$position = Engine_Api::_()->ynevent()->getPositionsAction($zipcode);
$values['lat'] = $position[0];
$values['lon'] = $position[1];
} catch (Exception $e) {
$values['lat'] = 0;
$values['lon'] = 0;
if (APPLICATION_ENV == 'development') {
throw $e;
}
}
// $values.
return $values;
}