Page 1 of 1

Hide "create new" link for a cross site lookup field

Posted: 25 Mar 2016
by mcgaafar
Hi,

I have a cross site lookup field on one of my form designer's forms that i'm toggling its readonly via js according to certain conditions. The field has "add new" link that i want to hide whenever i disable the field. How do i do that?

Thanks

Re: Hide "create new" link for a cross site lookup field

Posted: 25 Mar 2016
by rostislav
This would hide the button:

Code: Select all

fd.field('csl').control()._el().find('.plumsail-csl > a').hide();
csl is the internal name of the field. Note, you may also want to change height of the control when you hide the button

fd.field('csl').control()._el().css('height', '24px');

Re: Hide "create new" link for a cross site lookup field

Posted: 25 Mar 2016
by mcgaafar
Perfect, thanks a lot.

Re: Hide "create new" link for a cross site lookup field

Posted: 06 Apr 2016
by mcgaafar
This code is not working if the form is opened in modal view, any suggestion to fix this?

Re: Hide "create new" link for a cross site lookup field

Posted: 07 Apr 2016
by rostislav
Opening the form as a modal dialog will not influence this. Probably you are trying to do something different with it. Explain what you're trying to do and I may be able to advise you.

Re: Hide "create new" link for a cross site lookup field

Posted: 07 Apr 2016
by mcgaafar
i'm only trying to hide the link if the form was opened as modal via another form, so i used the same line of code that is working for me in the normal view and placed it inside the if statment that checks if window.top != window.self, but the link is still shown, i even tested more with the same line of code place on form load not inside the if statment to check, it doesn't work as well when the form is opened in modal view via another form

Re: Hide "create new" link for a cross site lookup field

Posted: 07 Apr 2016
by rostislav
Am I right to understand that you're trying to hide the button on form load?

Re: Hide "create new" link for a cross site lookup field

Posted: 07 Apr 2016
by mcgaafar
Actually no, i want to hide it only if the form is opened in modal view via another form, and this situation could happen via different forms. For example a user might be adding a project or a sales opportunity or whatever form that has a contact field(parent form), and then the user clicked on the add new contact link associated with the contact field on the parent form, so the contacts form(child) will be opened in modal view and taking the value of the parent company, now i don't want the contact form(child) to show add new company below the company field that is already auto-populated via the parent form.

Re: Hide "create new" link for a cross site lookup field

Posted: 08 Apr 2016
by rostislav
If I understood you correctly: Add the following CSS to the page:

Code: Select all

[fd_type="PlumsailLookup"] {
	height: 24px;
}

.plumsail-csl > a {
	display: none;
}

.plumsail-csl-add-visible [fd_type="PlumsailLookup"] {
	height: 41px;
}

.plumsail-csl-add-visible .plumsail-csl > a {
	display: inline;
}
Then you can use the following code to show the button when and as you need to:

Code: Select all

$('body').addClass('plumsail-csl-add-visible');