how to disable vtigercrm combo/select/picklist? - vtiger

i have a vtigercrm module that has a picklist field, I need it to be showed on edit view but not to be edited, is there a way to disable it?
I was thinking about using disabled or readonly prop

You have multiple option to make dropdown disabled.
Using JS you can disable the dropdown as per condition on on document ready
And you can add condition in \layouts\vlayout\modules\YOUR_MODULE\uitypes\Picklist.tpl
e.g.
{if $FIELD_MODEL->getFieldName() eq 'accountcustomersegment' && $FIELD_MODEL->get('fieldvalue') neq '' && $RECORD_ID neq '' }
<!-- HTML of select box and add disabled attribute in it -->
{else}
<!-- HTML of select box -->
{/if}
Here $FIELD_MODEL->get('fieldvalue') neq '' && $RECORD_ID neq '' has been checked becuse if you want to enable field in create view and disable it in edit view.
Hope it will help.

Related

Sitecore: RTE Paste as Plain Text customization

I was experimenting with RTE buttons and found that the copy pasting from word to RTE allows all styles to be intact. So i read a post and got rid of the extra formatting. Now i want to deal with blank spaces and line breaks. So, with some analysis i have decided to allow:
One blank space for single line break. Statements to be shown as single paragraph.For example
"This is new. </br> This is weird." should become "<p>This is new. This is weird.</p>"
If multiple line breaks are found, then all break separated statements should act as single paragraph with only single break between them. For example
"This is new. </br></br></br> This is weird." should become "<p>This is new.</p> </br> <p>This is weird.</p>"
This would be very efficient for authors which previously would need to adjust the whole scrap after pasting from word.
I have tried using the "Paste as Plain Text" button but it does not take care of line breaks. So i was wondering how i could customize the button function to adjust it to my needs? where and how should i do this ??
In web.config file, you can change and update HTMLEditor setting. However, you might have different aspect and dynamic user's input in the HTML editor. So, I would suggest you create a customize RichText Editor in Core DB and an assembly if you need. Then, create another config file in App_include folder to patch and add your customized HTML editor with different setting. Below is from web.config file and you can update this configuration if you want to keep using default RichText Editor.
<!-- HTML EDITOR DEFAULT CONFIGURATION TYPE
Specifies the type responsible for setting up the rich text editor. Can be overriden at profile level. Must inherit from
Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client.
Default value: Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client
-->
<setting name="HtmlEditor.DefaultConfigurationType" value="Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client" />
<!-- HTML EDITOR DEFAULT PROFILE
Path to the default html editor profile.
Default value: /sitecore/system/Settings/Html Editor Profiles/Rich Text Default
-->
<setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Profiles/Rich Text Default" />
<!-- HTML EDITOR LINE BREAK
Specifies the tag that the HTML editor inserts on Enter. Values can be
"br", "div" and "p".
-->
<setting name="HtmlEditor.LineBreak" value="p" />
<!-- HTML EDITOR REMOVE SCRIPTS
If true, the rich text editor removes script tags from RTE field values before saving. Setting the value to true reduces the potential for cross-site scripting and other script-related issues.
Default value: true
-->
<setting name="HtmlEditor.RemoveScripts" value="true" />
<!-- HTML EDITOR SUPPORT WEB CONTROLS
Indicates if the Html Editor supports web controls. If true, Web Controls are shown as yellow boxes.
Default value: true
-->
<setting name="HtmlEditor.SupportWebControls" value="true" />
<!-- HTML EDITOR VALIDATOR SERVICE URL
Specifies the url that validates XHtml.
-->
<setting name="HtmlEditor.ValidatorServiceUrl" value="http://validator.w3.org/check" />
You have to do this change in your Javascript... you can have custom JS when you are in authoring mode to catch the paste event and do the HTML manipulation in javascript...
An other option that would work as well in the ContentTree would be to add a button in the RTE that call this javascript, here you can find some explanation on how to add the button to the RTE.
https://markstiles.net/Blog/2011/02/05/adding-button-to-rich-text-editor.aspx

Coldfusion - How to prevent multiple clicks?

I have a button (anchor tag) that send a confirm message if you press it.
The problem is that for example if you press it 5 times very quickly it will send 5 confirm messages, if you press it 2 times it will send 2 messages.
This can occur when the user has low connection speed and while the page is refreshing he presses again the button.
How can I manage this situation? I though of disabling the button but for other reasons this is not possible.
<a class="msg" href="/manage/conversations.cfm?destination=#destination#">
#ucase(request.l('Send'))#
</a>
Thank you for your time
Ultimately, you need to have code on your server to prevent processing the link multiple times from the same user.
However, to solve the UI issue, have you link call a function instead of the cf file directly.
<a class="msg" href="javascript: processLink(#destination#);">
#ucase(request.l('Send'))#
</a>
<script>
runCount = 0;
function processLink(destination){
runCount++;
if (runCount == 1){
window.location.href = "/manage/conversations.cfm?destination=" + destination;
}
}
</script>
As mentioned in the previous answer it's nice to have some client side javascript to stop duplicate submissions from trigger happy users however you should also do this checking server side.
One approach would be to create a hidden formfield with a GUID that coldfusion generates when coldfusion renders your form.
So something like:
<cfset GUID = createUUID()>
<cfoutput>
<form id="frm" action="/target.cfm" method="post">
<input type="hidden" name="guid" value="#GUID#">
<!-- all your formfields go here -->
<input type="submit">
</form>
</cfoutput>
On the server side the target page then checks if it has already previously received the GUID. There are lots of ways to do, here are two of many ways.
a) Use Session Scope.
This is probably the quickest way if you are not running in a clustered environment and just need something quick for a tiny application.
<cfif isDefined("session.MYPAGE_GUID") AND session.MYPAGE_GUID EQ form.guid>
<cfoutput>Duplicate Form Submission</cfoutput>
<cfabort>
<cfelse>
<cfset session.MYPAGE_GUID = form.guid>
<!-- Do Business Logic Here -->
</cfif>
b) Use a Database Table.
Create a database table with a column called GUID. Make sure that GUID is the primary key or has a unique constraint.
Before you run your business logic insert the form.GUID into the database table. If you can do the insert process your business logic, if not the database query will throw an error that the record exists. You can then catch this error and take the appropriate action for a duplicate submission.
I prefer the database option as it works across clustered environments and database server are solid protecting against race conditions to ensure that a GUID is only set once.
Please be aware that this is just demonstrating the basic concepts and is not a drop in solution. There is a bit of more work to get these concepts into an e-commerce solution.
The best way is to disable the link once it's selected. If you don't want to do that, an alternative is to structure conversations.cfm like this.
<div id="pageContent">
small amount of text
</div>
<cfflush>
</body>
</html>
<cfsavecontent variable = "actualPageContent">
code
</cfsavecontent>
<cfoutput>
<script>
var #toScript(actualPageContent, "newPageContent")#;
document.getElementById("pageContent").innerHTML = "newPageContent";
</script>
</cfoutput>

Order details do not load

Shipping Method & Payment Method doesn't show at all but after I click Update Tools button it shows up. When I check the script it's called and loaded via AJAX.
Login to admin panel. Go to Sales > Orders > Click edit an order > Click Totals tab. Look at Order Details table below.
Here's a screenshot before I click Update Tools
And after I click on Update Tools
Here's the script which shows selectbox
<select name="payment">
<option value=""><?php echo $text_select; ?></option>
<?php if ($payment_code) { ?>
<option value="<?php echo $payment_code; ?>" selected="selected"><?php echo $payment_method; ?></option>
<?php } ?>
</select>
It seems $payment_code doesn't contain any loop that's why it doesn't seem to load all before I click the button.
The question is: Is it correct or is it a bug?
Did anyone ever take a look at payment and shipping method loading at all without clicking on "Update Tools" button?
I have compared with original script and the script is exactly the same.
Opencart Version: 1.5.6
It's correct, it shouldn't be a loop. $payment_code and $payment_method aren't arrays, they just contain one entry (the order's current payment method). Have a look at the getForm() method in the sale/order controller to confirm:
if (isset($this->request->post['payment_code'])) {
$this->data['payment_code'] = $this->request->post['payment_code'];
} elseif (!empty($order_info)) {
$this->data['payment_code'] = $order_info['payment_code'];
} else {
$this->data['payment_code'] = '';
}
This has been a headache a few times for some of my clients. I believe it's because it doesn't bother to calculate all relevant shipping methods in case you change the address. Ideally it should, and would recalculate when you change zone, but it doesn't, so... there ya go! Not a bug, just not ideal functionality.

Joomla 2.5 set module only on homepage

Hello am developer no administrator i have problem with my website (e-shop).
I use HikaShop componetn on my site and want to show last products on home page.
In Home page i add module and set position, and set in configuration to be visible only on HOME page. But dont work. I configure in administration where is visible where is not visible.
I try in my index manual to add
<div id="wraper">
<jdoc:include type="message" />
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault())
{?>
<jdoc:include type="modules" name="position-10" /><?php
} ?>
<jdoc:include type="component" />
</div><!--END OF WRAPER -->
I have top menu (HOME, AboutUs, Product, Contact) and when i click on About us and other page in top menu that module is not visible work fine. But on site i have sidebar where i show product categories. And there is problem, when i click on catetogy last product module is visible there.
Example:
--> TOP Menu
example.com -> TRUE = Module Last Product is Visible
example.com/index.php/abut-us -> FALSE = Module Last
Product is not Visible
example.com/index.php/product -> FALSE = Module Last
Product is not Visible
example.com/index.php/contact -> FALSE = Module Last
Product is not Visible
--> SIDEBAR
example.com/category/17-fishing-road -> TRUE = Module Last
Product is Visible
in all category is visible but i configure only on homepage
And in all sidebar is visible. Any idea how to fix this and put visible only on
example.com/index.php (HOMEPAGE)
Try this:
if(JRequest::getVar('view') == "frontpage" ) {
//You are in!
}
else {
//You are out!
}
The assignment of modules is done via the Module Manager, not the template index.php
Sp, go to the Module Manager (backend), open the module you want to assign, in the bottom left you can select which menu items you want to assign it to.
If it doesn't work using this method, then there must be something wrong with your site.
Hope this helps

ColdFusion variable not set properly

I have a form with some html elements. It has a check box which is by default checked. On click of the submit button it calls the submitForm function
Based on the checkbox condition it has to do the action. If the checkbox is Y, then it has to do one form action and if not checked then another action. Using javascript I have checked whether its checked or not. But I am not able to set the coldfusion variable for this. Always it overwrites the variable.
Below is the code snippet
This is the ColdFusion variable which is used. This is by default set to Y
<cfset form_condn_var = 'Y'/>
function submitForm(){
if (document.getElementById('Show_Final_Model').checked)
{
form.Show_Final_Model.value = 'Y';
}
else{
<cfset form_condn_var = 'N'/>
}
}
<cfif '<cfoutput>#form_condn_var#</cfoutput>' eq 'Y'>
<form id="form1" action="test.cfm" method="POST" target="testmain">
<cfelse>
<form id="form1" action="<cfoutput>#something#</cfoutput>" method="POST" target="_blank" onSubmit="">
</cfif>
It always set the variable form_condn_var as N and it goes to the else condition of the form irrespective of the condition. . But when I alert the value its comes correctly.
I cannot use hidden variable also as the form is not being called initially. Based on the checked condition only it is accessed.
Could somebody please tell me why the form_condn_var gets overwritten irrespective of the condition being checked.
Or is there any other way I can achieve this?
Thanks in advance
Short version
If I have understood your logic correctly then you can replace all of what you pasted with the following <cfif>
<cfif IsDefined('form.Show_Final_Model') AND form.Show_Final_Model EQ 'Y'>
<form id="form1" action="test.cfm" method="POST" target="testmain">
<cfelse>
<form id="form1" action="<cfoutput>#something#</cfoutput>" method="POST" target="_blank" onSubmit="">
</cfif>
Explanation
Your main problem here is that you have got Javascript outside of tags with a coldfusion within them and seem to be confusing what each language does.
First of all Coldfusion renders the HTML. As far as Coldfusion is concerned, the javascript if statement is just text, and so it sees the following logic
<cfset form_condn_var = 'Y'>
<cfset form_condn_var = 'N'>
<cfif form_condn_var EQ 'Y'> <!--- form_condn_var === '<cfoutput>#form_condn_var#</cfoutput>' but much cleaner --->
.......
<cfelse>
.......
</cfif>
In turn leading to the following HTML being rendered
function submitForm(){
if (document.getElementById('Show_Final_Model').checked)
{
form.Show_Final_Model.value = 'Y';
}
else{
}
}
<form id="form1" action="<cfoutput>#something#</cfoutput>" method="POST" target="_blank" onSubmit="">
I suspect in your example you trimmed out some logic though as otherwise that Javascript would be output as plaintext, as it is not within <script> tags.
If you are submitting your checkbox and then setting the form action for the next form (form 2 - after you've chosen the checkbox) I think what you want to do is the following:
<cfparam name="form.Show_Final_Model" default="N"/>
<cfif form.Show_Final_Model IS 'Y'>
<form id="form1" action="test.cfm" method="POST" target="testmain">
<cfelse>
<form id="form1" action="<cfoutput>#something#</cfoutput>"
method="POST" target="_blank" onSubmit="">
</cfif>
This would be on the handler page (after the form is submitted). You would not need the JS function.
If however you are trying to change the action param of your form to something else based on the check or uncheck of the checkbox (in other words - withing the same form) then ALL of your code needs to be javascript and CF has little to do with it. Set 2 variables - action a and action b, check the value of the checked form element and change the form.action value to whichever one you want.
But most importantly get settled in your mind on what is "server side" and what is "client side" .. that's where you are slipping up. good luck :)
I'm not sure if I'm understanding the question correctly, but it would seem that this situation could be handled purely on the action page based on conditional processing based on the result of the form checkbox value. Instead of sending the form to two different action templates based on the value of the checkbox, just process the form accordingly on the action template based on conditional processing of the checkbox form value.