Suite CRM - Add custom field in contacts subpanel of accounts detail page - sugarcrm

I wanted to create a 'Call Button' in the contacts sub panel of accounts details page. I could create 'Call button' in the contacts list page with logic hooks. But the same way of implementation is not working in the sub panel. (This button has no connection with the DB, it just trigger a JavaScript function when click on it.). Please help me on this.
Thanks in advance.

Take a look at modules/Contacts/metadata/subpanels/ForAccounts.php.
Why "ForAccounts"? It simply means that this Contacts sub panel will be loaded for the Accounts module. So that you can have different functionality for each module. default is simply the default sub panel used when a calling module is not specified. This is due to the way SuiteCRM handles relationships. You can specify in the relationship which subpanel should be displayed.
Notice the "top_buttons" array. These are the buttons at the top of the sub panel. The widget_class corresponds to the widgets in include/generic/SugarWidgets. Eg SubPanelTopCreateButton is actually SugarWidgetSubPanelTopCreateButton.
'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateButton'),
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'Contacts'),
),
If you wish to add your own button you must first create your own widget and then add it to the top_buttons array.
The sub panels use the following to generate the buttons
include/generic/LayoutManager.php
include/SubPanel/SubPanel.php:120
include/SubPanel/SubPanelTiles.php:426
You may have to register your widget with the layout manager.
SugarWidgets are a core feature and currently will not load from the custom directory.
Take a look at SugarWidgetSubPanelTopCreateTaskButton.php as a reference guide.

Related

Including list view of relationship entity on update page

I am trying to extend an update view to include a list view of some related items below the edit form.
I have two models, Publishers and Volumes, which have a many to many relationship. What I am trying to do is this.... when a user clicks on the edit button for a publisher, I want them to go to a page with the standard edit fields, but also have a list view below the form that lists all of the volumes that are connected to that publisher via their relationship.
Is there an easy way to do this?
I hope this makes sense.
As #tabacitu mentioned, Backpack doesn't currently have an built in solution for this. That said, this could maybe work for you:
This would allow you to use all functionality of the nested list view including interacting with the entities without conflicting at all with the parent
Step 1, Build your normal CRUDs
Build out two normal CRUDs, one for Publishers, and one for Volumes
Step 2, Make a frameless layout
copy vendor/backpack/base/layout.blade.php
name it frameless-layout.blade.php
remove #include('backpack::inc.main_header') and #include('backpack::inc.sidebar')
Step 3, Make a custom list view
copy vendor/backpack/crud/list.blade.php
name it sub-list.blade.php
change the top line to #extends('backpack::frameless-layout')
Step 4, Make a custom field
Create a custom form field that contains an iFrame
Inside your custom field template, have it set the url of the iFrame to the "list" url of the related resource
You'd also need to utilize List Filters and a method for setting them dynamically so that the sub-list shows only the records related to the parent
Step 5, Configure and use the field
In your crud controllers, use the addField to add the the configuration for the new field and its related model
Indeed, there's no standard functionality to do that in Backpack. It's a pretty unusual way to do things. But it's not too difficult to achieve it.
If there aren't too many Vendors for one Publisher (as I expect it's the case here), I would keep it simple and NOT try to include the entire Backpack list view (with ajax, buttons, filters, etc) on top of the form. I would add a standard HTML table with the entries (and optionally buttons to Edit Vendor with target=_blank).
Here's how I would go about it:
In the Publisher CRUD, I would use a custom view for the Edit operation; you can do that using $this->crud->setEditView('edit_publisher_with_vendors') in your setup() method;
In that custom edit view (edit_publisher_with_vendors.blade.php in my example), I would copy-paste everything inside the edit.blade.php view that Backpack/CRUD is using, and add a table with the Vendors on top of the Edit form; notice you have the current entry as $entry in this view; since there's a relationship on the model, you would be able to check if it has vendors using $entry->vendors()->count(), and get the vendors using $entry->vendors.
Hope it helps.

How to clear tabs while navigating within tabbedpanle in wicket

I'm building a tabbedpanel which consists of three tabs. I have a tab with form with text fields in it. while I am navigating from this tab I'm unable to loose the state of this tab. Can anyone suggest how to get around it?
Is the Form/ around the TabbedPanel? If YES then you can override
org.apache.wicket.extensions.markup.html.tabs.TabbedPanel#newLink()
And do something like:
form.setModelObject(new EmptyObject())
Or:
form.setModelObject(null)
Or:
use a visitor to set "empty"/null model for each FormComponent in the complete form
Or:
Just in the specific tab by using the passed 'index' parameter to #newLink().

How to add a basic signup form to a Concrete5 page template

I'm new to Concrete5 and have found a ton of information on adding contact forms, but only to the editable area of the page.
What I need to do is get a form into my page template. It's simply a name+email+submit button form to appear on every page for that template. On submission, a 'thanks' message... that's about it!
I've tried copy/pasting the code outputted into the page content to my default.php template but no luck with that. Thanks in advance for any help.
You should create a (global) editable area in the template, and then add a contact block to it just as you would otherwise.
E.g.:
<?php
$a = new GlobalArea('Contact Form');
$a->display();
?>
I agree with the other answer here... it's not worth the trouble to re-create a "hard-coded" contact form in your theme if you already have all the code working as a block. Here's a third technique you could use to achieve that -- you can hardcode just one block instead of the entire stack, like so:
<?php Block::getByName('My Global Contact Form')->display(); ?>
Put that code in your theme's template, and then add the contact form block to a stack in the dashboard (any stack, doesn't matter -- I usually create one stack of "global content" in my sites that I put all of these "hardcoded" blocks into). Then after you've added the block to the stack, click on the block and choose "Custom Template" from the popup menu. Then enter the block name into the field there (in this example, it would be "My Global Contact Form", without the quotes). Finally, click the "Approve Changes" button at the top of the stack.
You could approach this a couple of ways, but one way is to create a stack that has an contact form in it. Then, take the name of that stack and add it to your template.
So if the stack is called "Global Contact Form", then you could add the following to your template:
$stack = Stack::getByName('Global Contact Form');
if( $stack ) $stack->display();

Want to display an auto generated id in a custom module of SugarCRM

I am using Sugar Enterprise 6.4.0 and want to display a uneditable field in a custom module Edit and Detail view. This id need to be generated automatcially and need to be displayed in the interface when user click to create a new record in the custom module.
Because i am new to Sugar can anyone help me out in performing this task. Any ideas?
You can set the readonly property on the field itself in the vardefs for the module...
$dictionary['<<module>>']['fields']['<<fieldname>>']['readonly'] = true;
Then, add some logic in the custom/modules/<>/views/view.edit.php which does the autogeneration for you.
I just did this, using an after_save_hook with code like(not exact):
$bean->name = $bean->id;
as soon as you save a record in sugar an id is generated automatically. Then I don't include the ID in the editview at all, just the detail and list views. I don't see any point in including it in the edit view as it is not editable.

How do I add a form to a view with drupal 6.x views 2?

I want to add a drupal form to the top of a view. The view does not need to receive the results of the form but the _submit hook of the form should be able to read the first argument of the view that the form was on.
Where is the best place to add this? Custom module or template file and what are the necessary filenames/hooks?
It appears the hook you want is
_views_pre_view
with variables $view, $display_id, $args and you want to set $view->attachment_before to equal the form.