How to add datepicker in tpl file sugarcrm - sugarcrm

I want to add start date and end date field in the datepicker format in my tpl file. How can I do it using jQuery? And how to include jQuery coding in the tpl file?.

You can find the code for a date time field in the file: include\SugarFields\Fields\Datetime\EditView.tpl.
The JavaScript code can be inserted the same way as in a .html file. The only difference is the brackets, ldelim for "{" and rdelim for "}".
<script type="text/javascript">
Calendar.setup ({ldelim}
{rdelim}
);
</script>

Related

Multiple language code in the same file - Visual Studio Code

actually I'm working with .phtml file and it works fine for HTML part of it.
But it doesn't recognize JS inside the script: Image->1
JS is total-white... how can I fix it?
OFC I need both at the same time.
Edit:
For example:
<div dojoType="dijit.form.Form" id="insCliFo" jsId="insCliFo">
<script type="dojo/method" event="onShow">
var f1=false;
var idWebAzienda = "";
if('<?=$this->az?>'=="69691c7bdcc3ce6d5d8a1361f22d04ac"){
window.progressDialog.show('Caricamento...');
dojo.xhrPost({
url: stdUrl("cdamodificare",'<?=$this->c?>'),
load: function(data){
window.progressDialog.close();
data=JSON.parse(data);
dijit.byId('ragSoc').attr("value",data.items.RagioneSociale);
dijit.byId('indirizzo').attr("value",data.items.indirizzoResidenza);
dijit.byId('nCivico').attr("value",data.items.nCivico);
dijit.byId('stato').attr("value",data.items.idStato);
f1=data.items.idProvincia+"~"+data.items.Comune+"~"+data.items.CAP;
dijit.byId('cap').attr("value",data.items.CAP);
dijit.byId('piva').attr("value",data.items.PIVA);
dijit.byId('cf').attr("value",data.items.CodF);
if(data.items.idTipo==0)
.
.
.
the div and the script are correctly "colorized"... but the Javascript inside the script is completly "black/white"...

Gravity Form Field Focus

I want to to add focus on the first field of my gravity form my form if is 39 and the first field id is 1 can someone can tell me how can I achieve this and what code I need and where to paste that code, for your information i am using hello elementor theme.
Please help me with code or snippet.
Add the following to an HTML field at the top of your form:
<script>
jQuery(document).ready(function($) { jQuery('#input_39_1').focus(); });
</script>

Scala format is causing issues when saving my main.js file in play

original:
<script src="#routes.Assets.versioned("javascripts/main.js")" type="text/javascript"></script>
Scala formatted:
<script src="#routes.Assets.versioned(" javascripts/main.js")" type="text/javascript"></script>
It is adding a space where the filename is, how can I fix this?
Is it better to have scala fmt somehow ignore js files?
Try to exclude js files for scalafmt. Can you try this to add to .scalafmt.conf:
project.excludeFilters = [
"public/javascripts/.*"
".*\\.js"
".*html.*"
]
But I'm not sure, I can't test it now. Note, scalafmt won't fix broken format after adding these lines. You should do it manually
UPDATE:
I could reproduce that issue on my machine also, but scalafmt is not changing html files. But Intellij Idea does, you can disable them for a scpefic block or entire file by adding this on top of your file
// #formatter:off
Source
It is the editor formatter that tries to space out attributes. Not the scala formatter.
Quick workaround is to use single quotes for the attributes.
<script src='#routes.Assets.versioned("javascripts/main.js")' type="text/javascript"></script>

Tip: How to add placeholder to textarea in Ninja Forms Wordpress plugin

This is actually not a question. I just felt that I needed to share this small piece of magic with all peeps out there having a hard time with getting a placeholder in the Ninja Forms textarea field.
So, basically what you need to do is add the following code to your header.php file in the head section, then change the ID of the textarea and choose your placeholder text.
<script type="text/javascript">
jQuery(document).ready(function($){
$('#yourTextareaID').attr("placeholder","Your placeholder value");
});
</script>
Hope this can help you save some time. You can thank me later.
A way of doing this to make it work for any textarea would be to set (in Ninja forms) the default value of the textarea as whatever you want the placeholder to be and then on page load, take the content of the each textarea, add it to the placeholder attribute, then remove the content:
$(document).ready(function() {
// Remove textarea content and add placeholder
$("textarea").each(function() {
var $this = $(this);
$this.attr("placeholder", $this.val());
$this.val("");
});
});
Great! Thanks. In my case the ID was 30, so my code ended up being:
<script type="text/javascript">
jQuery(document).ready(function($){
$('#ninja_forms_field_30').attr("placeholder","Your placeholder value");
});
</script>

Kendo datepicker acting weired for different computers on two different timezone

Hi we use a simple kendo datepicker for our web application.
$("#DateInput").kendoDatePicker({
format: "dd/MM/yyyy",
culture: "en-GB",
max: new Date()
});
Now when we try to get the datepicker value in Javascript my browser gives me date format dd/MM/yyyy but my colleague's browser gives him MM/dd/yyyy. We have tried to use same culture as you can see in kendo and as well as in our web.config we have put the globalization settings as follows.
<system.web>
<globalization uiCulture="en-GB" culture="en-GB" />
</system.web>
My computer's date format and settings are as follows;
Region & Language format: English(United Kinddom)
Keyboard Layout: English(United Kingdom)
Long and Short Date format: dd MMMM yyyy
Timezone: GMT+6
My colleague's date format and settings are;
Region & Language format: English(Australia)
Keyboard Layout: English(Australia)
Long and Short Date format: dd MMMM yyyy
Timezone: GMT+8
Last bit of information, we are using Chrome for testing on both places. It is probably the UTC problem. I want the date format in "dd/MM/yyyy" for both occasion. Any workable solution will be highly appreciated. Thanks.
Try to add this code at top of your page before you gonna render any kendo widget:
kendo.culture("en-GB");
It should forced kendo widgets to work in all location using en-GB culture.
If you're using ASP.MVC I recommend add it in "_Layout.cshtml" like:
<head>
...
<script src="#Url.Content("~/Scripts/jquery/jquery-1.8.2.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Kendo/js/kendo.all.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Kendo/js/kendo.aspnetmvc.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Kendo/js/cultures/kendo.culture.pl-PL.min.js")"></script>
<script src="#Url.Content("~/Kendo/js/cultures/kendo.culture.en-GB.min.js")"></script>
<script src="#Url.Content("~/Kendo/js/cultures/kendo.culture.de-DE.min.js")"></script>
<script type="text/javascript">
kendo.culture("en-GB");
</script>
//widgets create scripts for your views if you write it here
</head>
Detail on globalization can be found on this link:
http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/globalization
If your intention is to convert the date into your desired format "dd/MM/yyyy" and if your kendo grid is not providing you the correct result in different places, create your own. Some thing like this.
In Json:
var FixedDateFormat = "PlodDate: '" + (Date.getUTCDate() + 1) + "/" + (Date.getUTCMonth() + 1) + "/" + Date.getUTCFullYear() + " 00:00:00";
Here I have added 1 on Date and Month cause getUTCDate/Month starts from 0. As you have said in comments you are accepting the date as string and then converting that back to DateTime so I've added the time " 00:00:00".
In MVC: You probably need to do something like following to convert;
DateTime X = Convert.ToDateTime(PlodDate);
UPDATE
I've got a better solution for you on JS. You are reading datepicker value with something like this, right??
$("#YourDatePickerName").data("kendoDatePicker").value()
Here you can tell your browser what local you want to use like the following
$("#YourDatePickerName").data("kendoDatePicker").value().toLocaleString("en-GB");
Which will generate exact same result for every culture.
Further Update
If you want to do it Kendo's way then you can use kendo.toString(). You can check it here.