I have created a custom form class and template for my form by following the instructions here.
However I am having trouble with adding DateFields with calendars. Usually I just do something like this:
$dateField = new DateField ('DateRequired', 'Date Required');
$dateField->setConfig ('showcalendar', true);
I have tried the above code in my custom form however the page doesn't include any of the jquery ui scripts or css files for the calendar field.
So my question is how can I get the my custom form to include all the scripts and render the fields with the jquery ui calendars?
actually the change of the template should not be necessary.
$dateField = new DateField('...');
$dateField->setConfig('showcalendar', true);
$dateField->setConfig('showdropdown', true);
$dateField->setConfig('dateformat', 'dd.MM.YYYY');
Ok I have worked it out. The code within the template that calls the fields needs to be changed from:
$dataFieldByName(DateRequired)
to:
$dataFieldByName(DateRequired).FieldHolder
Now all of the javascript is included within the page.
Related
I looked around and could not find the solution as to how to add a custom class to the form element/elements or the <form> tag for that matter. I have a custom form validation function which does some custom validation. form_set_error does set an error class on the elements but I wanted to add my custom class anywhere within the form tag.
Since the goal is just to customize the display of your field on error, a cleaner way is to create your own theme_form_element() in your theme and use the function form_get_error($element) to add the class you want if any error is returned on a field.
Using this method you can also display the error message next to the field in error, instead of on top of the form.
I found the answer here. Turns out you can use $form_state to make alterations to form after submission. I did
if($haserror) {
$form_state['complete form']['#attributes'] = array('class'=>array('contains_error'));
}
I have created a new property in DTM. Added header and footer code from DTM in the new website. I am using adobe's s_code version which i have set in the property. When I created a page load rule for custom tracking of the navigation it says "Uncaught Reference Error" s is not defined.
The page load rule that i have added is
//links tracking
$("a.top-nav-link").click(function() {
_satellite.notify('top nav clicked');
var tophatlinks = "ntap:TH:" + $(this).text();
s.eVar14 = tophatlinks;
s.linkTrackVars = "eVar14";
s.tl(this,'o');
});
But If i use event based rule it works and doesn't give the error. Since I have to use many click events I thought of adding one page rule and add all the custom tracking there. But this is not working. Any thoughts?
In DTM, s isn't a global variable so it cannot be directly referenced in some code fields.
However inside a rule, you can open the Adobe Analytics accordion and click 'custom page code' which open open a code editor where you can reference s without any issues.
So we currently have Jira in our workplace and no Jira Administrator. I'm feeling up to the task and would like to know if Jira has the functionality I'm looking for.
So when you have comments in Jira or even in the body of a Jira ticket. You can italicize the text from the comment ribbon
As you can see I am interested in being able to have the same functionality as bold or italicize or underline
but I want to be able to highlight some code that i insert in a ticket comment and click a button and make it into a code block. Or add curly brackets and make it a quote... Exactly like how StackOverflow does it.
Anyone know how I can accomplish this?
This is quite old question but it might help someone else looking for an answer later...
If you're familiar with JavaScript, simply inject a button via JS onto the toolbar. I've done this for a couple of custom fields. Such JS can be included in the custom field's description.
Example
In my case, I've added two buttons on two custom fields to copy original content from Summary/Description. You can adjust the code to do a whatever action on any custom field or comment field.
Screenshot
Code
Code to be included in the custom field's description. Adjust your code to place the JS into appropriate elements.
<script>
var cfAltDescription = 14705;
var elAltDescription = AJS.$("#customfield_" + cfAltDescription);
function addDescriptionButton() {
var buttonHTML = ' <button type="button" class="aui-button" style="font-size: 11px;padding: 1px 5px;" title="Paste original description into this field" onclick="copyDescription()">< Description</button>';
AJS.$(".jira-wikifield[field-id=customfield_" + cfAltDescription + "] ~ .wiki-button-bar").append(buttonHTML);
}
function copyDescription() {
var origDescription = AJS.$("#description").attr("value");
elAltDescription.attr("value", origDescription);
// set focus in the input box after copying...
elAltDescription.focus()[0].setSelectionRange(0, 0);
elAltDescription.scrollTop(0);
}
addDescriptionButton();
</script>
For comments, you cannot inject JS into the custom field description (comments are not a custom field). You will need to include your JS either via Announcement Banner (this would be global JS for any Jira page). Alternatively, you can utilize simple yet powerful JsIncluder add-on to inject your own JS code only for certain project/issuetype or globally and/or for edit/transition screens only.
I think you can use plugin for this. jeditor plugin gives you more options in text editors. all information you need is provided in above link.after installing this plugin you can change the text renderer as "JEditor Renderer".
Marketplace: https://marketplace.atlassian.com/plugins/com.jiraeditor.jeditor
or you can use.....
Note:-I guess this is not the exact answer you need but I think you can use macros inside the comment field. ex:if you want to add panel in inside of comment you can simply use
{panel}Some text{panel}
{panel:title=My Title}Some text with a title{panel}
{panel:title=My Title| borderStyle=dashed| borderColor=#ccc| titleBGColor=#F7D6C1| bgColor=#FFFFCE}
a block of text surrounded with a *panel*
yet _another_ line
{panel}
and if you want to add code you can use...
--- Java example ---
{code:title=Bar.java|borderStyle=solid}
// Some comments here
public String getFoo()
{
return foo;
}
{code}
*--- XML example ---*
{code:xml}
<test>
<another tag="attribute"/>
</test>
{code}
here is a example screenshot..
follow this link for more information..
UPDATE
with the plugin you can get something like this..I think this will helps you.
When i call Gravity Form in my theme's functions.php using ajax the form fields are disabled.
Any solutions will help me a lot.
add_action('wp_head', 'mytheme_fn');
add_action('wp_ajax_mythem_load_gravityform', 'mythem_load_gravityform_call');
function mytheme_fn(){
?>
<script>
jQuery(document).ready(function () {
var data = {
action: 'mythem_load_gravityform'
};
jQuery.post(
ajaxurl,
data
).success(function (data) {
jQuery('.gformholder').html(data);
});
});
</script> <?php }
function mythem_load_gravityform_call(){
gravity_form(1, false, false, false, null,false);
exit;
}
Thank you in advance.
From a Gravity Forms Support Specialist:
"The issue is caused by GF's implementation of the form rendering logic. They check whether is_admin() returns true (and it does when you call ajax on Wordpress) and if so, they render it like you were in admin."
We have made a number of changes in Gravity Forms 1.9 so and is_admin check is no longer performed when loading forms and fields, which means forms and fields can now be loaded via AJAX and they will render correctly.
Gravity Forms 1.9 has just been released: http://www.gravityhelp.com/gravity-forms-v1-9-released/
Regarding the enhanced ui, this is powered by the chosen.js script and when you make change to the underlying select element you will need to trigger an update of the chosen interface: http://harvesthq.github.io/chosen/options.html#triggerable-events
The issue is caused by GF's implementation of the form rendering logic. They check whether is_admin() returns true (and it does when you call ajax on Wordpress) and if so, they render it like you were in admin.
I can think of two solutions here:
1) dummy endpoint
create a dummy page with template file without head or foot, just a plain gravity_form(...);
Then call this url from your js.
2) plugin
create a plugin, which registers custom query var (using query_vars filter), and then process the query variable by showing the gravity_form(...) output.
I am currently writing a ContentManager in ASP.NET. I have a preview button which uses jQuery to post the form data to new window and shows how a page would look without saving it to the database and effecting the live site. Although its been somewhat of a hassle to get ASP.NET to post directly to the page I am trying to preview, I've finally worked it all out using a series of jQuery code. It worked beautifully, I loaded all the post values into the page using Request.Form and displayed them on the page. Unfortunately for some reason the Telerik RadEditor's I was using were posting me the values they had been assigned on the C# Page_Load event and did not reflect the text changes I made. If anyone could help me out that would be great.
function showPreview()
{
url = "<%= (SiteManager.GetSite()).Url + this.Filename %>?preview=true";
var specs = "width=1010,height=700,location=0,resizeable=1,status=1,scrollbars=1";
window.open(url, 'PagePreview', specs).moveTo(25, 25);
$("#__VIEWSTATE").remove();
$("#__EVENTTARGET").remove();
$("#__EVENTARGUMENT").remove();
$("#aspnetForm").removeAttr("action");
$("#aspnetForm").attr("target","PagePreview");
$("#aspnetForm").attr("action", url);
$("#aspnetForm").submit();
}
Here is all the post data I am receiving from the tererik RADEDITOR ::
[ctl00_MainContentPlaceHolder_SideContentRadEditor_dialogOpener_Window_ClientState] => [ctl00_MainContentPlaceHolder_SideContentRadEditor_dialogOpener_ClientState] => [ctl00$MainContentPlaceHolder$SideContentRadEditor] => [ctl00_MainContentPlaceHolder_SideContentRadEditor_ClientState] => [ctl00_MainContentPlaceHolder_ContentRadEditor_dialogOpener_Window_ClientState] => [ctl00_MainContentPlaceHolder_ContentRadEditor_dialogOpener_ClientState] => [ctl00$MainContentPlaceHolder$ContentRadEditor] => %3cp%3eTestPageContent%3c/p%3e
This is the html value of the text editor (shown above) %3cp%3eTestPageContent%3c/p%3e
This is the value in the RadEditor that was loaded during the Page_Load event.
I changed the value to "Test". But it was not sent over the POST Request, it sent what was loaded in the page load.
The editor content area is separate from the textarea used to submit the content during a POST request. The editor will automatically try to save the content in the hidden textarea when the form is submitted, but in your case no event is fired because it happens programmatically (i.e. you call .submit()). You will need to tell the editor to save its content manually before you do the postback. The code is pretty basic - get a reference to the editor and call .saveContent():
//Grab a reference to the editor
var editor = $find("<%=theEditor.ClientID%>");
//Store the content in the hidden textarea so it can be posted to the server
editor.saveContent();
One solution would be to grab the current HTML in the editor in your showPreview method and pass that manually. To do that, add a hidden input element in your page to hold the HTML content:
<input type="hidden" id="htmlContent" name="htmlContent" />
Then, you can set that intput's value in showPreview like this:
function showPreview()
{
url = "<%= (SiteManager.GetSite()).Url + this.Filename %>?preview=true";
var specs = "width=1010,height=700,location=0,resizeable=1,status=1,scrollbars=1";
window.open(url, 'PagePreview', specs).moveTo(25, 25);
$("#__VIEWSTATE").remove();
$("#__EVENTTARGET").remove();
$("#__EVENTARGUMENT").remove();
// *** Begin New Code ***
//Grab a reference to the editor
var editor = $find("<%=theEditor.ClientID%>");
//Get the current HTML content
var html = editor.get_html()
//Put that HTML into this input so it will get posted
$("#htmlContent").val(html);
// *** End New Code ***
$("#aspnetForm").removeAttr("action");
$("#aspnetForm").attr("target","PagePreview");
$("#aspnetForm").attr("action", url);
$("#aspnetForm").submit();
}
Then when you want to get the HTML during the postback you can just use Request.Form["htmlContent"]
One caveat: Since you'll be posting raw HTML, ASP.NET's Request Validation might cause problems. One of the major purposes of that validation is to make sure that HTML content doesn't get posted back to the server - the very thing you're trying to accomplish. You could of course turn the validation off (see the link above) but the validation is there for a reason. Another solution might be to do some basic encoding of the HTML before you post it. If you just replace all less-than symbol (<) with something before posting it, ASP.Net will be happy. Then you just need to 'un-replace' it during the postback.