How to change required field error message? - sharepoint-2010

I have two required columns in a custom list. When adding an item using OOTB new form, the required field validator shows same error message "You can't leave this blank." for both required columns. Does anybody know what is the best way to show different messages for each of them?

You can use Strings.STS to override message. Just add this code to your page or master page if you want to apply all your site.
<script type="text/javascript">
$(document).ready(function () {
try {
if (Strings.STS.L_SPClientRequiredValidatorError != null) {
Strings.STS.L_SPClientRequiredValidatorError = "What ever you want!";
}
}
catch (exception) { }
});
</script>
For more information: SharePoint 2010 use message: "You must specify a value for this required field." It showed after validating from the server. SharePoint 2013 shows a message "You can't leave this blank." after validating from the client.
But, if you use Sharepoint webpart and Sharepoint control, it still shows a message same as Sharepoint 2010. It makes inconsistent from your site.

Related

How to show custom notifications or error message at admin panel for prestashop 1.7.7.7?

​
Hi, 
I've been trying a lot of options to manage an exception and show an error at admin panel but nothing seems to work.
I'm at the postProcess method of a custom module. After the user sends a csv file through a form and the data is checked (everything works fine here), if an exception occurs I need to show a message, stop and redirect to the same page. 
I've tried this: 
this->get('session')->getFlashBag()->add('error',$msg);
Tools::redirectAdmin('index.php?controller='.$controller.'&token='.$token);
this: 
header("HTTP/1.0 400 Bad Request");
die(json_encode(array( 'error' => array($this->l(' Error') ))));
(that one works but shows a blank page with the message, not the message inside the admin panel) 
also this: 
$this->context->smarty->assign(array(
'token' => Tools::getAdminTokenLite('AdminModules'),
'errors' => $this->errors
));
$this->setTemplate('ExcelProcess.tpl');
and {$errors|var_dump} at the tpl displays null...
... and many other options. 
I can't find anything either about backoffice custom notifications at the PS docs, only about front custom notifications.
Any clue? 
 
Thanks a lot! 
Miguel
PostProces code: https://drive.google.com/file/d/175nhUPDlzi6T8rZjjE8Desnzq-mtYzNQ/view?usp=sharing
​Tpl code: https://drive.google.com/file/d/17EONOCJ60L4Gp_GidzvwCQwMyTrRXapF/view?usp=sharing
Adding an error in postProcess() can be achieved by setting
$this->errors[] = $this->l('My error');
or
$this->context->controller->errors[] = $this->l('My error');
during your form submission checks.
Form will be rendered with your error messages into a red box.
If you want to show an alert without reloading the page instead, you'll have to perform an AJAX call to your AdminController, get back a JSON response and render your error message as a result of the execution of the call.
See offical docs

x-editable render html error response

We have a system where customer information is editable in-line.
When someone puts in an email that already exists, I want to return the error message:
Email already exists. <a href='/find-duplicates/id'>Click here to find possible duplicates of this customer</a>
I would like the user to be able to click on the link when s/he sees the error message. The error message is very easy to send; it's rendering the html that's the problem.
Trying to display same kind of link in x-editable field error as #iateadonut.
For anyone wanting to display html in x-editable errors, assuming you have the error with html sent back from server with response status code different from 500 (400 maybe) try :
$(function() {
$('#your_field_id').editable({
error: function(response, newValue) {
if(response.status === 500) {
return 'Service unavailable. Please try later.';
} else {
var error = $.parseHTML( response.responseText )
$(".editable-error-block").html(error)
}
},
});
})
Mostly html parsing response error and injecting it inside x-editable error block.
Found in x-editable doc, options.

Google Maps Api --> One project works without API KEY but another not

i've got two PHP projects in which i use the Google Maps Api to convert adress data into geo coordinates. The first project uses this code (i post ir here in a shorted version) and works:
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script>
function latlong(adresse) {
geocoder = new google.maps.Geocoder();
if (geocoder) {
geocoder.geocode( { 'address': adresse}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
// I NEVER GET IN HERE with my second project
alert("It works!");
} else {
alert('It works not');
}
});
}
}
// Start Converting
latlong('teststreet 10, 91578 Leuterhausen');
As you can see, i don't use an API Key in this section
<script src="https://maps.googleapis.com/maps/api/js"></script>
but it works anyway (Alert box "It works" is shown).
Now i have built another project with the same code but it does not work (Alert Box "It works not" is shown).
Do you have any idea...
...why the first project works WITHOUT an API key?
...what i have to change in the code so that the second project works?
When i use this code in the header
<script src="https://maps.googleapis.com/maps/api/js?key=[here i place in my key]"
async defer></script>
i get the error message: "Google Maps API error: ApiNotActivatedMapError https://developers.google.com/maps/documentation/javascript/error-messages#api-not-activated-map-error"
How can i activate the key?
Every help is appreciated.
Best regards
Daniel
If the app has been running before google enforced the use of API keys the app should still run, apps published after the change will require the key ...read here : https://developers.google.com/maps/pricing-and-plans/standard-plan-2016-update

How to a hide a page

I have a pop up that is called through a java script, the same pop up without a JavaScript is an ctp page in cakephp. How can I hide that page from users and search engines going to access it like: /users/register
Is there anything that can be done in .htaccess or cakephp to prevent access to it through /users/register
Remove register.ctp file from users folder and create one in ajax folder users/ajax/register.ctp, then use RequestHandler component to inspect request type:
public function register()
{
if($this->request->is('ajax')){
// add registration code here
} else {
//Throw new error
}
}

Meteor IronRouter onBeforeAction causes exception in defer callback

I'm trying to secure my meteor app with iron-router, here's my onBeforeAction function:
this.route('manageUsers', {
path: '/panel/user_management',
layoutTemplate: 'panel',
onBeforeAction: function(){
if((Meteor.user() === null)||(Meteor.user().role !== 'superAdmin')){
Router.go('signIn');
throwAlert('You dont have access to see this page', 'notification');
}
}
});
When I'm trying to go to /panel/user_management subpage by pressing a link button everything goes fine (user is redirected etc.), but when I type the path directly in my browser (localhost:3000/panel/user_management) and hit enter user is not getting redirected and I receive in console Exception in defer callback error. Anyone know what I'm doing wrong?
For additional information, this view lists me all users registered. When I go to this path normally (without error) I see complete user list. When I receive error template doesn't appear in > yield.
Finally, I've solved this - the problem was wrong if statement, here's the correct one:
if((!Meteor.user())||(Meteor.user().role !== 'superAdmin')){}