tomasi Posted January 21, 2014 Share Posted January 21, 2014 Hi,Can you please help me? I would like to display custom message warning and success when people using my form module. The custom warning message would for example: "You must enter your name"Thank you in advance ! Link to comment Share on other sites More sharing options...
vekia Posted January 21, 2014 Share Posted January 21, 2014 but the question is: where, in back office, front office you want to display this warning / success ? and after what actions? Link to comment Share on other sites More sharing options...
tomasi Posted January 21, 2014 Author Share Posted January 21, 2014 I want display the message like the maintenance message of prestashop in red for warning and in green for success. Link to comment Share on other sites More sharing options...
vekia Posted January 21, 2014 Share Posted January 21, 2014 but where? and after what action? without actions? Link to comment Share on other sites More sharing options...
tomasi Posted January 21, 2014 Author Share Posted January 21, 2014 This function display error when users don't wrtite in a form: public function displayError($errorList) { $errorString = ""; foreach( $errorList as $key => $value ) { $errorString .= $value."<br/>"; //$this->hook($params); } echo '<span class="warning" style="display: block;">'.$errorString.'</span>'; } I want to display $errorString in a custom message warning Link to comment Share on other sites More sharing options...
vekia Posted January 21, 2014 Share Posted January 21, 2014 still no answer where exactly, it's most important question Link to comment Share on other sites More sharing options...
lpbellier Posted January 23, 2014 Share Posted January 23, 2014 He probably means after entering your information, right under the field that is missing the info in the form. Link to comment Share on other sites More sharing options...
EricPham Posted March 9, 2015 Share Posted March 9, 2015 (edited) You can display success by using $this->confirmations[] = "Successful message"; And error: $this->errors[] = Tools::displayError("Your error"); Edited March 9, 2015 by EricPham (see edit history) 1 Link to comment Share on other sites More sharing options...
xiparos Posted April 25, 2015 Share Posted April 25, 2015 I see nowhere the syntax $this->confirmations[] in PS, could you please show me an example in PS ? Link to comment Share on other sites More sharing options...
mohamd.sobhy Posted September 27, 2016 Share Posted September 27, 2016 i want to disable warning .. when it asking for saving many times in > adding new product in file AdminProductsController.php when it say $this->displayWarning($this->l('You must save this product before adding specific pricing')); i just want to save once when it finish adding product public function initFormPrices($obj) { $data = $this->createTemplate($this->tpl_form); $product = $obj; if ($obj->id) { $shops = Shop::getShops(); $countries = Country::getCountries($this->context->language->id); $groups = Group::getGroups($this->context->language->id); $currencies = Currency::getCurrencies(); $attributes = $obj->getAttributesGroups((int)$this->context->language->id); $combinations = array(); foreach ($attributes as $attribute) { $combinations[$attribute['id_product_attribute']]['id_product_attribute'] = $attribute['id_product_attribute']; if (!isset($combinations[$attribute['id_product_attribute']]['attributes'])) { $combinations[$attribute['id_product_attribute']]['attributes'] = ''; } $combinations[$attribute['id_product_attribute']]['attributes'] .= $attribute['attribute_name'].' - '; $combinations[$attribute['id_product_attribute']]['price'] = Tools::displayPrice( Tools::convertPrice( Product::getPriceStatic((int)$obj->id, false, $attribute['id_product_attribute']), $this->context->currency ), $this->context->currency ); } foreach ($combinations as &$combination) { $combination['attributes'] = rtrim($combination['attributes'], ' - '); } $data->assign('specificPriceModificationForm', $this->_displaySpecificPriceModificationForm( $this->context->currency, $shops, $currencies, $countries, $groups) ); $data->assign('ecotax_tax_excl', (float)$obj->ecotax); $this->_applyTaxToEcotax($obj); $data->assign(array( 'shops' => $shops, 'admin_one_shop' => count($this->context->employee->getAssociatedShops()) == 1, 'currencies' => $currencies, 'countries' => $countries, 'groups' => $groups, 'combinations' => $combinations, 'multi_shop' => Shop::isFeatureActive(), 'link' => new Link(), 'pack' => new Pack() )); } else { $this->displayWarning($this->l('You must save this product before adding specific pricing')); $product->id_tax_rules_group = (int)Product::getIdTaxRulesGroupMostUsed(); $data->assign('ecotax_tax_excl', 0); } $address = new Address(); $address->id_country = (int)$this->context->country->id; $tax_rules_groups = TaxRulesGroup::getTaxRulesGroups(true); $tax_rates = array( 0 => array( 'id_tax_rules_group' => 0, 'rates' => array(0), 'computation_method' => 0 ) ); foreach ($tax_rules_groups as $tax_rules_group) { $id_tax_rules_group = (int)$tax_rules_group['id_tax_rules_group']; $tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator(); $tax_rates[$id_tax_rules_group] = array( 'id_tax_rules_group' => $id_tax_rules_group, 'rates' => array(), 'computation_method' => (int)$tax_calculator->computation_method ); if (isset($tax_calculator->taxes) && count($tax_calculator->taxes)) { foreach ($tax_calculator->taxes as $tax) { $tax_rates[$id_tax_rules_group]['rates'][] = (float)$tax->rate; } } else { $tax_rates[$id_tax_rules_group]['rates'][] = 0; } } // prices part $data->assign(array( 'link' => $this->context->link, 'currency' => $currency = $this->context->currency, 'tax_rules_groups' => $tax_rules_groups, 'taxesRatesByGroup' => $tax_rates, 'ecotaxTaxRate' => Tax::getProductEcotaxRate(), 'tax_exclude_taxe_option' => Tax::excludeTaxeOption(), 'ps_use_ecotax' => Configuration::get('PS_USE_ECOTAX'), )); $product->price = Tools::convertPrice($product->price, $this->context->currency, true, $this->context); if ($product->unit_price_ratio != 0) { $data->assign('unit_price', Tools::ps_round($product->price / $product->unit_price_ratio, 6)); } else { $data->assign('unit_price', 0); } $data->assign('ps_tax', Configuration::get('PS_TAX')); $data->assign('country_display_tax_label', $this->context->country->display_tax_label); $data->assign(array( 'currency', $this->context->currency, 'product' => $product, 'token' => $this->token )); $this->tpl_form_vars['custom_form'] = $data->fetch(); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now