Suit CRM check box displayed as drop down - sugarcrm

In Edit view check box filed displays as check box.
But in advanced search, check box displayed as drop down.
in popup defs field type is bool. how to display this as a check-box in advanced search ?

That is the default of Suite/Sugar CE CRM which display checkbox as a drop-down in advance search. It is defined by field type and you will need to override that field in an upgrade-safe manner(by copying in the custom folder while keeping their current folder hierarchy).
Check complete code inside this file: include/SugarFields/Fields/Bool/SearchView.tpl and do changes as you want. you will see tpl files for other views as well.

1.-You need to create a file: custom/include/SugarFields/Fields/Bool/SearchView.tpl
2.-Copy this code:
{if strval({{sugarvar key='value' stringFormat='false'}}) == "1" || strval({{sugarvar key='value' stringFormat='false'}}) == "yes" || strval({{sugarvar key='value' stringFormat='false'}}) == "on"}
{assign var="checked" value='checked="checked"'}
{else}
{assign var="checked" value=""}
{/if}
<input type="hidden" name="{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}" value="0">
<input type="checkbox" id="{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}"
name="{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}"
value="1" title='{{$vardef.help}}' tabindex="{{$tabindex}}" {{if !empty($displayParams.accesskey)}} accesskey='{{$displayParams.accesskey}}' {{/if}}
{$checked} {{$displayParams.field}}>
3.-Do a Repair/Rebuild.

Related

Get Date Products last updated in Opencart 3

I am trying to get the latest date from Opencart 3 Products field 'Date_available' and post it into the very top of the header page. I am currently doing it by manually adding the date in the settings/store page where I have placed a text box linked to the database variable - I use the code in cotroller Settings.php:
if (isset($this->request->post['config_updated'])) {
$data['config_updated'] = $this->request->post['config_updated'];
} else {
$data['config_updated'] = $this->config->get('config_updated');
}
and the code in sttings twig:
<div class="form-group">
<label class="col-sm-2 control-label" for="input-updated">{{ entry_updated }}</label>
<div class="col-sm-10">
<input type="text" name="config_updated" value="{{ config_updated}}" placeholder="{{ entry_updated}}" id="input-updated" class="form-updated" />
</div>
</div>
Here I can enter the date and it shows as image:
enter image description here Products last updated: 25/05/2020 : 21:12:32
How can I find the latest date in oc_products_date_available and show it in the place described above? Any help appreciated.
Here are all the steps.
First of all, backup your files.
Then,
go to folder:
catalog/model/catalog
Inside the folder common create a new file called
headerdate.php
Inside the headerdate.php add the following code:
<?php
class ModelCatalogHeaderdate extends Model {
public function getLastDate() {
$query = $this->db->query("SELECT date_available FROM `" . DB_PREFIX . "product` ORDER BY `date_available` DESC LIMIT 1");
return $query->row['date_available'];
}
}
Save the changes.
Now open file:
catalog/controller/common/header.php
and before the line:
return $this->load->view('common/header', $data);
add the following code:
$this->load->model('catalog/headerdate');
$data['last_product_update'] = $this->model_catalog_headerdate->getLastDate();
Save settings and you've completed the hard part.
Now, the last and easiest part, is that you open your theme's header.twig file and you can show your date by using the variable we've set above like this:
{{ last_product_update }}
Don't forget to save your changes and upload them to your eshop.

How do I bind a value to a textbox in Angular2?

I have been trying to figure out how to bind a value to a textbox in Angular2. Currently I have a textbox with a placeholder that is loaded with a predetermined value.
<input id="textbox" class="k-textbox" placeholder={{label}} />
But once I change a value of a date component, I would want the placeholder value to be updated to the date value selected. So far i wrote this but this doesn't seem to be working. Please advice.
date-component.html
<input id="datepicker" (input)="changeLabel()"/>
date-component.ts
label:string;
constructor() {
this.label = 'Select Date';
}
changeLabel() {
this.label = 'Date Selected';
}
}
use an click event to propagate the changes.
date-component.html
<input id="datepicker" (click)="changeLabel()"/> //<-- click event
You could use two way databinding with NgModel.
https://angular.io/docs/ts/latest/guide/template-syntax.html#!#ngModel
Basically this would make "label" change to whatever the user types.
<input [(ngModel)]="label" id="datepicker" />
You will also need to import FormsModule in your app.
Plunker to show what I mean:
https://plnkr.co/edit/CfmalT7GesrP5lzBsNFx?p=preview
use keyup Event
<input (keyup)="changeLabel()">
enter the value its call the keyup event

TYPO3 index_search no markup result in FLUID/ExtBase

In default indexsearch extension i have highlighted keywords in search result, but when i use FLUID version it not work, I find that are different function it Controller, witch prepared description for default template and for FLUID.
typo3/sysext/indexed_search/Classes/Controller/SearchController.php
452 line --- prepared for FLUID
$resultData['description'] = $this->makeDescription(
$row,
(bool)!($this->searchData['extResume'] && !$headerOnly),
$this->settings['results.']['summaryCropAfter']
);
(bool)!($this->searchData['extResume'] && !$headerOnly) shoud give 'false' but didn't. I check ts extResume = 1 and headerOnly = false. So it seems to be wrong construction?
When replace the (bool)!($this->searchData['extResume'] && !$headerOnly) to false. I get murkups but also i needed change output format in fluid template
from ---
...
<f:if condition="{row.headerOnly} == 0">
<p class="tx-indexedsearch-description">{row.description}</p>
...
to -----
...
<f:if condition="{row.headerOnly} == 0">
<p class="tx-indexedsearch-description"><f:format.html>{row.description}</f:format.html></p>
...
Now it work, but i still don't understand why it not work by default?
There is an alternative Method:
In the Searchform define a hidden Field: (Resource/Private/Partials/Form.html)
<f:form.hidden name="search[extResume]" value="1" />
In Searchsresult.html i would use format.raw instead of format.html.
<p class="tx-indexedsearch-description"><f:format.raw>{row.description}</f:format.raw>
I think its a bug - I already created a bugreport for this.
https://forge.typo3.org/issues/77682
Maybe you can provide a patch and push it to the review-system - that would be very helpful!

Adding Bootstrap 3 popover breaks JQuery Validation Plugin

I have a form, which I'm validating using JQuery Validation plugin. Validation works file until I add a Bootstrap 3 popover to the text field with name "taskName" (the one being validated) (please see below) . When I add the popover to this text field, error messages are repeatedly displayed every time the validation gets triggered. Please see the code excerpts and screenshots below.
I've been trying to figure out what is happening, with no success so far. Any help will be greatly appreciated. Thanks in advance!
HTLM Excerpt
The popover content
<div id="namePopoverContent" class="hide">
<ul>
<li><small>Valid characters: [a-zA-Z0-9\-_\s].</small></li>
<li><small>Required at least 3 characters.</small></li>
</ul>
</div>
The form
<form class="form-horizontal" role="form" method="post" action="" id="aForm">
<div class="form-group has-feedback">
<label for="taskName" class="col-md-1 control-label">Name</label>
<div class="col-md-7">
<input type="text" class="form-control taskNameValidation" id="taskName" name="taskName" placeholder="..." required autocomplete="off" data-toggle="popover">
<span class="form-control-feedback glyphicon" aria-hidden="true"></span>
</div>
</div>
...
</form>
JQuery Validate plugin setup
$(function() {
//Overwriting a few defaults
$.validator.setDefaults({
errorElement: 'span',
errorClass: 'text-danger',
ignore: ':hidden:not(.chosen-select)',
errorPlacement: function (error, element) {
if (element.is('select'))
error.insertAfter(element.siblings(".chosen-container"));
else
error.insertAfter(element);
}
});
//rules and messages objects
$("#aForm").validate({
highlight: function(element) {
$(element).closest('.form-group').removeClass('has-success').addClass('has-error');
$(element).parent().find('.form-control-feedback').removeClass('glyphicon-ok').addClass('glyphicon-remove');
},
success: function(element) {
$(element).closest('.form-group').removeClass('has-error').addClass('has-success');
$(element).parent().find('.form-control-feedback').removeClass('glyphicon-remove').addClass('glyphicon-ok');
}
});
$('.taskNameValidation').each(function() {
$(this).rules('add', {
required: true,
alphanumeric: true,
messages: {
required: "Provide a space-separated name."
}
});
});
});
Bootstrap 3 popover setup
$('[data-toggle="popover"]').popover({
trigger: "focus hover",
container: "body",
html: true,
title: "Name Tips",
content: function() { return $('#namePopoverContent').html();}
});
The screenshots
First Edit
It seems I did not make my question clear, so here it goes my first edit.
I'm not using the popover to display the error messages of the validation. The error messages are inserted after each of the fields that fail validation, which is precisely what I want. Hence, this question does not seem to be a duplicate of any other question previously asked.
Regarding the popover, I just want to add an informative popover that gets displayed whenever the user either clicks the text field "taskName" or hovers the mouse over it. Its role is completely independent of the validation.
The question is, then, why adding the (independent) popover is making the validation plugin misbehave, as shown in the screenshots.
I had the very same issue a few days ago and the only solution I found was to use 'label' as my errorElement:.
Change the line errorElement: 'span' to errorElement: 'label' or simply removing the entire line will temporarily fix the issue. ('label' is the default. )
I am not completely sure what the JQ validate + BS popover conflict is, but I will continue to debug.
After some debugging I think I found the issue.
Both jQuery validate and bootstrap 3 popovers are using the aria-describedby attribute. However, the popover code is overwriting the value written by jQuery validate into that attribute.
Example: You have a form input with an id = "name", jQuery validate adds an aria-describedby = "name-error" attribute to the input and creates an error message element with id = "name-error" when that input is invalid.
using errorElement:'label' or omitting this line works because on line 825 of jquery.validate.js, label is hard-coded as a default error element selector.
There are two ways to fix this issue:
Replace all aria-describedby attributes with another attribute name like data-describedby. There are 4 references in jquery.validate.js. Tested.
or
Add the following code after line 825 in jquery.validate.js. Tested.
if ( this.settings.errorElement != 'label' ) {
selector = selector + ", #" + name.replace( /\s+/g, ", #" ) + '-error';
}
I will also inform the jQuery validate developers.
The success option should only be used when you need to show the error label element on a "valid" element, not for toggling the classes.
You should use unhighlight to "undo" whatever was done by highlight.
highlight: function(element) {
$(element).closest('.form-group').removeClass('has-success').addClass('has-error');
$(element).parent().find('.form-control-feedback').removeClass('glyphicon-ok').addClass('glyphicon-remove');
},
unhighlight: function(element) {
$(element).closest('.form-group').removeClass('has-error').addClass('has-success');
$(element).parent().find('.form-control-feedback').removeClass('glyphicon-remove').addClass('glyphicon-ok');
}
(The success option could also be used in conjunction with the errorPlacement option to show/hide tooltips or popovers, just not to do the styling, which is best left to highlight and unhighlight.)
Also, I recommend letting the Validate plugin create/show/hide the error label element, rather than putting it the markup yourself. Otherwise, the plugin will create its own and ignore the one you've created.
In case you were unaware, you cannot use the alphanumeric rule without including the additional-methods.js file.

How to hide a text field in play framework

How to hide a text field in play framework? For example how to hide this field:
#inputText(userProfileForm("name"), '_label -> "Name")
This should work in all browsers:
#inputText(
userProfileForm("name"),
'_label -> "Name",
'style -> "display: none"
)
Note that this only hides the field, not the label etc.
If you want to hide the label aswell, you can't do this with the default helpers.
You can however specify the input field yourself:
<input type="hidden" name="name" value="#userProfileForm.data.get("name")" />
The name should be name of the field in your form (coincidentally name aswell in this case).
I haven't tested the value but it should work, maybe you'll need to strip the " around name.
If you do this, the hidden data will be sent, along with the other data in the form to the server.
Edit:
If the hidden value is empty, that means you didn't bind it to the form when calling the view. You can bind the name to the form like this in Java (I don't know Scala, but it's explained in the Play Scala documentation):
Map<String, String> data = new HashMap<>();
data.put("name","get the username here");
return ok(index.render(userProfileForm.bind(data));
Another option (which is cleaner in my opinion) is to simply pass the username as an argument to the view. The controller becomes:
return ok(index.render(userProfileForm, "username goes here"));
And in the view you can then simply do:
#(userProfileForm : Form[UserProfileForm])(name : String)
#helper.form(...){
<input type="hidden" name="name" value="#name" />
//...
}
The inputText helper takes a varargs of (Symbol, Any), which represent the html attributes. If you are using html5 you can just add the hidden attribute:
#inputText(userProfileForm("name"), '_label -> "Name", 'hidden -> "hidden")
normally the hidden attribute has no value, but I couldn't find any information about how to do this with the helpers. In Chrome at least it works like this as well.
edit:
btw, you can also just use html instead of the helper:
<input attribute=value hidden />
I know that this is an old question, but i had a similar issue, i wanted to hide an inputText and still, handle it using the helpers.
The best and cleanest way to do it is to write your own helper adding a custom value to tell when to hide the element itself.
I came to a solution like this
my own field constructor
#(elements: helper.FieldElements)
#if(elements.args.contains('hideIt)){
#elements.input
}else{
<div class="#if(elements.hasErrors) {error}">
<div class="input">
#elements.input
<span class="errors">#elements.errors.mkString(", ")</span>
<span class="help">#elements.infos.mkString(", ")</span>
</div>
</div>
}
that i used in the view file like this:
#inputText(form("fieldName"),
'hidden -> "true",
'hideIt -> true
)
now you are done :)
While it worked, I didn't like the hashmap version provided by #Aerus, preferring to use the statically typed forms when possible, so I came up with an alternative.
final UserProfileForm initial = new UserProfileForm("get the username here");
return ok(index.render(Form.form(UserProfileForm.class).fill(initial));
Then, in the profile, you can do as follows:
<input type="hidden" name="name" value="#userProfileForm("name").value" />