本文整理汇总了PHP中Form::addElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addElement方法的具体用法?PHP Form::addElement怎么用?PHP Form::addElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form::addElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$language = OW::getLanguage();
$config = OW::getConfig();
OW::getDocument()->setHeading(OW::getLanguage()->text('admin', 'heading_mobile_settings'));
OW::getDocument()->setHeadingIconClass('ow_ic_gear_wheel');
$settingsForm = new Form('mobile_settings');
$disableMobile = new CheckboxField('disable_mobile');
$disableMobile->setLabel($language->text('admin', 'mobile_settings_mobile_context_disable_label'));
$disableMobile->setDescription($language->text('admin', 'mobile_settings_mobile_context_disable_desc'));
$settingsForm->addElement($disableMobile);
$submit = new Submit('save');
$submit->setValue($language->text('admin', 'save_btn_label'));
$settingsForm->addElement($submit);
$this->addForm($settingsForm);
if (OW::getRequest()->isPost()) {
if ($settingsForm->isValid($_POST)) {
$data = $settingsForm->getValues();
$config->saveConfig('base', 'disable_mobile_context', (bool) $data['disable_mobile']);
OW::getFeedback()->info($language->text('admin', 'settings_submit_success_message'));
} else {
OW::getFeedback()->error('Error');
}
$this->redirect();
}
$disableMobile->setValue($config->getValue('base', 'disable_mobile_context'));
}
示例2: __construct
/**
* Constructor.
*/
public function __construct($ajax = false)
{
parent::__construct();
$form = new Form('sign-in');
$form->setAction("");
$username = new TextField('identity');
$username->setRequired(true);
$username->setHasInvitation(true);
$username->setInvitation(OW::getLanguage()->text('base', 'component_sign_in_login_invitation'));
$form->addElement($username);
$password = new PasswordField('password');
$password->setHasInvitation(true);
$password->setInvitation('password');
$password->setRequired(true);
$form->addElement($password);
$remeberMe = new CheckboxField('remember');
$remeberMe->setValue(true);
$remeberMe->setLabel(OW::getLanguage()->text('base', 'sign_in_remember_me_label'));
$form->addElement($remeberMe);
$submit = new Submit('submit');
$submit->setValue(OW::getLanguage()->text('base', 'sign_in_submit_label'));
$form->addElement($submit);
$this->addForm($form);
if ($ajax) {
$form->setAjaxResetOnSuccess(false);
$form->setAjax();
$form->setAction(OW::getRouter()->urlFor('BASE_CTRL_User', 'ajaxSignIn'));
$form->bindJsFunction(Form::BIND_SUCCESS, 'function(data){if( data.result ){if(data.message){OW.info(data.message);}setTimeout(function(){window.location.reload();}, 1000);}else{OW.error(data.message);}}');
$this->assign('forgot_url', OW::getRouter()->urlForRoute('base_forgot_password'));
}
$this->assign('joinUrl', OW::getRouter()->urlForRoute('base_join'));
}
示例3: index
public function index($params = array())
{
$userService = BOL_UserService::getInstance();
$language = OW::getLanguage();
$this->setPageHeading($language->text('hotlist', 'admin_heading_settings'));
$this->setPageHeadingIconClass('ow_ic_gear_wheel');
$settingsForm = new Form('settingsForm');
$settingsForm->setId('settingsForm');
$expiration_time = new TextField('expiration_time');
$expiration_time->setRequired();
$expiration_time->setLabel($language->text('hotlist', 'label_expiration_time'));
$expiration_time_value = (int) OW::getConfig()->getValue('hotlist', 'expiration_time') / 86400;
$expiration_time->setValue($expiration_time_value);
$settingsForm->addElement($expiration_time);
$submit = new Submit('save');
$submit->addAttribute('class', 'ow_ic_save');
$submit->setValue($language->text('hotlist', 'label_save_btn_label'));
$settingsForm->addElement($submit);
$this->addForm($settingsForm);
if (OW::getRequest()->isPost()) {
if ($settingsForm->isValid($_POST)) {
$data = $settingsForm->getValues();
OW::getConfig()->saveConfig('hotlist', 'expiration_time', $data['expiration_time'] * 86400);
OW::getFeedback()->info($language->text('hotlist', 'settings_saved'));
$this->redirect();
}
}
}
示例4: __construct
public function __construct(BASE_CommentsParams $params, $id, $formName)
{
parent::__construct();
$language = OW::getLanguage();
$form = new Form($formName);
$textArea = new Textarea('commentText');
$textArea->setHasInvitation(true);
$textArea->setInvitation($language->text('base', 'comment_form_element_invitation_text'));
$form->addElement($textArea);
$hiddenEls = array('entityType' => $params->getEntityType(), 'entityId' => $params->getEntityId(), 'displayType' => $params->getDisplayType(), 'pluginKey' => $params->getPluginKey(), 'ownerId' => $params->getOwnerId(), 'cid' => $id, 'commentCountOnPage' => $params->getCommentCountOnPage(), 'isMobile' => 1);
foreach ($hiddenEls as $name => $value) {
$el = new HiddenField($name);
$el->setValue($value);
$form->addElement($el);
}
$submit = new Submit('comment-submit');
$submit->setValue($language->text('base', 'comment_add_submit_label'));
$form->addElement($submit);
$form->setAjax(true);
$form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment'));
// $form->bindJsFunction(Form::BIND_SUBMIT, "function(){ $('#comments-" . $id . " .comments-preloader').show();}");
// $form->bindJsFunction(Form::BIND_SUCCESS, "function(){ $('#comments-" . $id . " .comments-preloader').hide();}");
$this->addForm($form);
OW::getDocument()->addOnloadScript("window.owCommentCmps['{$id}'].initForm('" . $textArea->getId() . "', '" . $submit->getId() . "');");
$this->assign('form', true);
$this->assign('id', $id);
}
示例5: index
public function index()
{
$language = OW::getLanguage();
$billingService = BOL_BillingService::getInstance();
$adminForm = new Form('adminForm');
$element = new TextField('creditValue');
$element->setRequired(true);
$element->setLabel($language->text('billingcredits', 'admin_usd_credit_value'));
$element->setDescription($language->text('billingcredits', 'admin_usd_credit_value_desc'));
$element->setValue($billingService->getGatewayConfigValue('billingcredits', 'creditValue'));
$validator = new FloatValidator(0.1);
$validator->setErrorMessage($language->text('billingcredits', 'invalid_numeric_format'));
$element->addValidator($validator);
$adminForm->addElement($element);
$element = new Submit('saveSettings');
$element->setValue($language->text('billingcredits', 'admin_save_settings'));
$adminForm->addElement($element);
if (OW::getRequest()->isPost()) {
if ($adminForm->isValid($_POST)) {
$values = $adminForm->getValues();
$billingService->setGatewayConfigValue('billingcredits', 'creditValue', $values['creditValue']);
OW::getFeedback()->info($language->text('billingcredits', 'user_save_success'));
}
}
$this->addForm($adminForm);
$this->setPageHeading(OW::getLanguage()->text('billingcredits', 'config_page_heading'));
$this->setPageTitle(OW::getLanguage()->text('billingcredits', 'config_page_heading'));
$this->setPageHeadingIconClass('ow_ic_app');
}
示例6: __construct
public function __construct($userId)
{
parent::__construct();
$data = OW::getEventManager()->call("photo.entity_albums_find", array("entityType" => "user", "entityId" => $userId));
$albums = empty($data["albums"]) ? array() : $data["albums"];
$source = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_source", $userId);
$this->assign("source", $source == "album" ? "album" : "all");
$selectedAlbum = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_album", $userId);
$form = new Form("pcGallerySettings");
$form->setEmptyElementsErrorMessage(null);
$form->setAction(OW::getRouter()->urlFor("PCGALLERY_CTRL_Gallery", "saveSettings"));
$element = new HiddenField("userId");
$element->setValue($userId);
$form->addElement($element);
$element = new Selectbox("album");
$element->setHasInvitation(true);
$element->setInvitation(OW::getLanguage()->text("pcgallery", "settings_album_invitation"));
$validator = new PCGALLERY_AlbumValidator();
$element->addValidator($validator);
$albumsPhotoCount = array();
foreach ($albums as $album) {
$element->addOption($album["id"], $album["name"] . " ({$album["photoCount"]})");
$albumsPhotoCount[$album["id"]] = $album["photoCount"];
if ($album["id"] == $selectedAlbum) {
$element->setValue($album["id"]);
}
}
OW::getDocument()->addOnloadScript(UTIL_JsGenerator::composeJsString('window.pcgallery_settingsAlbumCounts = {$albumsCount};', array("albumsCount" => $albumsPhotoCount)));
$element->setLabel(OW::getLanguage()->text("pcgallery", "source_album_label"));
$form->addElement($element);
$submit = new Submit("save");
$submit->setValue(OW::getLanguage()->text("pcgallery", "save_settings_btn_label"));
$form->addElement($submit);
$this->addForm($form);
}
示例7: getAdminInterface
public function getAdminInterface()
{
$st = "select ecomm_product.id as product_id, ecomm_product.name as product_name,\n\t\t\t\tecomm_product.supplier as supplier_id, ecomm_supplier.name as supplier_name, ecomm_product.price as product_price\n\t\t\t\tfrom ecomm_product left join ecomm_supplier on ecomm_product.supplier = ecomm_supplier.id\n\t\t\t\torder by ecomm_supplier.name,ecomm_product.name";
$products = Database::singleton()->query_fetch_all($st);
$formPath = "/admin/EComm§ion=Plugins&page=ChangeProductPrice";
$form = new Form('change_product_prices', 'post', $formPath);
if ($form->validate() && isset($_REQUEST['submit'])) {
foreach ($products as $product) {
$ECommProduct = new Product($product['product_id']);
$ECommProduct->setPrice($_REQUEST['product_' . $product['product_id']]);
$ECommProduct->save();
}
return "Your products' prices have been changed successfully<br/><a href='{$formPath}'>Go back</a>";
}
$oldSupplier = 0;
$currentSupplier = 0;
$defaultValue = array();
foreach ($products as $product) {
$currentSupplier = $product['supplier_id'];
if ($oldSupplier != $currentSupplier) {
$form->addElement('html', '<br/><br/><hr/><h3>Supplier: ' . $product['supplier_name'] . '</h3>');
}
$form->addElement('text', 'product_' . $product['product_id'], $product['product_name']);
$defaultValue['product_' . $product['product_id']] = $product['product_price'];
$oldSupplier = $product['supplier_id'];
}
$form->addElement('submit', 'submit', 'Submit');
$form->setDefaults($defaultValue);
return $form->display();
}
示例8: settings
public function settings()
{
$adminForm = new Form('adminForm');
$language = OW::getLanguage();
$config = OW::getConfig();
$element = new TextField('autoclick');
$element->setRequired(true);
$validator = new IntValidator(1);
$validator->setErrorMessage($language->text('autoviewmore', 'admin_invalid_number_error'));
$element->addValidator($validator);
$element->setLabel($language->text('autoviewmore', 'admin_auto_click'));
$element->setValue($config->getValue('autoviewmore', 'autoclick'));
$adminForm->addElement($element);
$element = new Submit('saveSettings');
$element->setValue($language->text('autoviewmore', 'admin_save_settings'));
$adminForm->addElement($element);
if (OW::getRequest()->isPost()) {
if ($adminForm->isValid($_POST)) {
$values = $adminForm->getValues();
$config = OW::getConfig();
$config->saveConfig('autoviewmore', 'autoclick', $values['autoclick']);
OW::getFeedback()->info($language->text('autoviewmore', 'user_save_success'));
}
}
$this->addForm($adminForm);
}
示例9: __construct
public function __construct()
{
parent::__construct();
$language = OW::getLanguage();
$serviceLang = BOL_LanguageService::getInstance();
$addSectionForm = new Form('qst_add_section_form');
$addSectionForm->setAjax();
$addSectionForm->setAjaxResetOnSuccess(true);
$addSectionForm->setAction(OW::getRouter()->urlFor("ADMIN_CTRL_Questions", "ajaxResponder"));
$input = new HiddenField('command');
$input->setValue('addSection');
$addSectionForm->addElement($input);
$qstSectionName = new TextField('section_name');
$qstSectionName->addAttribute('class', 'ow_text');
$qstSectionName->addAttribute('style', 'width: auto;');
$qstSectionName->setRequired();
$qstSectionName->setLabel($language->text('admin', 'questions_new_section_label'));
$addSectionForm->addElement($qstSectionName);
$this->addForm($addSectionForm);
$addSectionForm->bindJsFunction('success', ' function (result) {
if ( result.result )
{
OW.info(result.message);
}
else
{
OW.error(result.message);
}
window.location.reload();
} ');
}
示例10: render
public function render($stat_id = null)
{
global $rm_form_diary;
echo '<div class="rmagic">';
//$this->form_number = $rm_form_diary[$this->form_id];
$form = new Form('form_' . $this->form_id . "_" . $this->form_number);
$form->configure(array("prevent" => array("bootstrap", "jQuery", "focus"), "action" => "", "class" => "rmagic-form", "name" => "rm_form", "number" => $this->form_number, "view" => new View_UserForm(), "style" => isset($this->form_options->style_form) ? $this->form_options->style_form : null));
//Render content above the form
if (!empty($this->form_options->form_custom_text)) {
$form->addElement(new Element_HTML('<div class="rmheader">' . $this->form_options->form_custom_text . '</div>'));
}
if ($this->is_expired()) {
if ($this->form_options->form_message_after_expiry) {
echo $this->form_options->form_message_after_expiry;
} else {
echo '<div class="rm-no-default-from-notification">' . RM_UI_Strings::get('MSG_FORM_EXPIRY') . '</div>';
}
echo '</div>';
return;
}
if ($stat_id) {
$form->addElement(new Element_HTML('<div id="rm_stat_container" style="display:none">'));
$form->addElement(new Element_Number('RM_Stats', 'stat_id', array('value' => $stat_id, 'style' => 'display:none')));
$form->addElement(new Element_HTML('</div>'));
}
parent::pre_render();
$this->base_render($form);
parent::post_render();
echo '</div>';
}
示例11: Form
function person_enter_render_xml()
{
$form = new Form();
$form->addElement(new FormInputElement("first_name", "Voornaam"));
$form->addElement(new FormInputElement("initials", "Voorletters"));
$form->addElement(new FormInputElement("last_name_prefix", "Tussenvoegsel"));
$form->addElement(new FormInputElement("last_name", "Achternaam"));
$form->addElement(new FormInputElement("email_address", "E-mail adres", "email"));
return $form->GenerateForm(NULL, "Voer persoonsgegevens in");
}
示例12: Form
function render_xml()
{
$form = new Form();
$form->addElement(new FormInputElement("address_street", "Straat"));
$form->addElement(new FormInputElement("address_number", "Huisnummer"));
$form->addElement(new FormInputElement("address_postalcode", "Postcode"));
$form->addElement(new FormInputElement("address_city", "Stad"));
//$form->addElement(new FormInputElement("address_province","Provincie"));
//$form->addElement(new FormInputElement("address_country","Land")); //!! ISO CODE, DROPDOWN
return $form->GenerateForm(NULL, "Voer adresgegevens in");
}
示例13: __construct
public function __construct($entityType, $entityId, $displayType, $pluginKey, $ownerId, $commentCountOnPage, $id, $cmpContextId, $formName)
{
parent::__construct();
$language = OW::getLanguage();
//comment form init
$form = new Form($formName);
$textArea = new Textarea('commentText');
$form->addElement($textArea);
$entityTypeField = new HiddenField('entityType');
$form->addElement($entityTypeField);
$entityIdField = new HiddenField('entityId');
$form->addElement($entityIdField);
$displayTypeField = new HiddenField('displayType');
$form->addElement($displayTypeField);
$pluginKeyField = new HiddenField('pluginKey');
$form->addElement($pluginKeyField);
$ownerIdField = new HiddenField('ownerId');
$form->addElement($ownerIdField);
$attch = new HiddenField('attch');
$form->addElement($attch);
$cid = new HiddenField('cid');
$form->addElement($cid);
$commentsOnPageField = new HiddenField('commentCountOnPage');
$form->addElement($commentsOnPageField);
$submit = new Submit('comment-submit');
$submit->setValue($language->text('base', 'comment_add_submit_label'));
$form->addElement($submit);
$form->getElement('entityType')->setValue($entityType);
$form->getElement('entityId')->setValue($entityId);
$form->getElement('displayType')->setValue($displayType);
$form->getElement('pluginKey')->setValue($pluginKey);
$form->getElement('ownerId')->setValue($ownerId);
$form->getElement('cid')->setValue($id);
$form->getElement('commentCountOnPage')->setValue($commentCountOnPage);
$form->setAjax(true);
$form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment'));
$form->bindJsFunction(Form::BIND_SUBMIT, "function(){ \$('#comments-" . $id . " .comments-preloader').show();}");
$form->bindJsFunction(Form::BIND_SUCCESS, "function(){ \$('#comments-" . $id . " .comments-preloader').hide();}");
$this->addForm($form);
if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed()) {
$attachmentCmp = new BASE_CLASS_Attachment($id);
$this->addComponent('attachment', $attachmentCmp);
}
OW::getDocument()->addOnloadScript("owCommentCmps['{$id}'].initForm('" . $form->getElement('commentText')->getId() . "', '" . $form->getElement('attch')->getId() . "');");
$this->assign('form', true);
$this->assign('id', $id);
if (OW::getUser()->isAuthenticated()) {
$currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
$this->assign('currentUserInfo', $currentUserInfo[OW::getUser()->getId()]);
}
}
示例14: __construct
public function __construct()
{
parent::__construct();
$language = OW::getLanguage();
$form = new Form("change-user-password");
$form->setId("change-user-password");
$oldPassword = new PasswordField('oldPassword');
$oldPassword->setLabel($language->text('base', 'change_password_old_password'));
$oldPassword->addValidator(new OldPasswordValidator());
$oldPassword->setRequired();
$form->addElement($oldPassword);
$newPassword = new PasswordField('password');
$newPassword->setLabel($language->text('base', 'change_password_new_password'));
$newPassword->setRequired();
$newPassword->addValidator(new NewPasswordValidator());
$form->addElement($newPassword);
$repeatPassword = new PasswordField('repeatPassword');
$repeatPassword->setLabel($language->text('base', 'change_password_repeat_password'));
$repeatPassword->setRequired();
$form->addElement($repeatPassword);
$submit = new Submit("change");
$submit->setLabel($language->text('base', 'change_password_submit'));
$form->setAjax(true);
$form->addElement($submit);
if (OW::getRequest()->isAjax()) {
$result = false;
if ($form->isValid($_POST)) {
$data = $form->getValues();
BOL_UserService::getInstance()->updatePassword(OW::getUser()->getId(), $data['password']);
$result = true;
}
echo json_encode(array('result' => $result));
exit;
} else {
$messageError = $language->text('base', 'change_password_error');
$messageSuccess = $language->text('base', 'change_password_success');
$js = " owForms['" . $form->getName() . "'].bind( 'success',\n function( json )\n {\n \tif( json.result == true )\n \t{\n \t \$('#TB_closeWindowButton').click();\n \t OW.info('{$messageSuccess}');\n }\n else\n {\n OW.error('{$messageError}');\n }\n\n } ); ";
OW::getDocument()->addOnloadScript($js);
$this->addForm($form);
$language->addKeyForJs('base', 'join_error_password_not_valid');
$language->addKeyForJs('base', 'join_error_password_too_short');
$language->addKeyForJs('base', 'join_error_password_too_long');
//include js
$onLoadJs = " window.changePassword = new OW_BaseFieldValidators( " . json_encode(array('formName' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Join", "ajaxResponder"), 'passwordMaxLength' => UTIL_Validator::PASSWORD_MAX_LENGTH, 'passwordMinLength' => UTIL_Validator::PASSWORD_MIN_LENGTH)) . ",\n " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . " ); ";
$onLoadJs .= " window.oldPassword = new OW_ChangePassword( " . json_encode(array('formName' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . " ); ";
OW::getDocument()->addOnloadScript($onLoadJs);
$jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
OW::getDocument()->addScript($jsDir . "base_field_validators.js");
OW::getDocument()->addScript($jsDir . "change_password.js");
}
}
示例15: index
public function index()
{
$groups = MODERATION_BOL_Service::getInstance()->getContentGroups();
if (OW::getRequest()->isPost()) {
$selectedGroups = empty($_POST["groups"]) ? array() : $_POST["groups"];
$types = array();
foreach ($groups as $group) {
$selected = in_array($group["name"], $selectedGroups);
foreach ($group["entityTypes"] as $type) {
$types[$type] = $selected;
}
}
OW::getConfig()->saveConfig("moderation", "content_types", json_encode($types));
OW::getFeedback()->info(OW::getLanguage()->text("moderation", "content_types_saved_message"));
$this->redirect(OW::getRouter()->urlForRoute("moderation.admin"));
}
$this->setPageHeading(OW::getLanguage()->text("moderation", "admin_heading"));
$this->setPageTitle(OW::getLanguage()->text("moderation", "admin_title"));
$form = new Form("contentTypes");
$submit = new Submit("save");
$submit->setLabel(OW::getLanguage()->text("admin", "save_btn_label"));
$form->addElement($submit);
$this->addForm($form);
$this->assign("groups", $groups);
}