Forums › Forums › OroCRM › OroCRM – Programming Questions › How to add a field to Log Call window
This topic contains 3 replies, has 2 voices, and was last updated by Mike Kudelya 7 years, 10 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- May 25, 2016 at 11:22 am #25206
Hello Folks
I need to add a simple field, actually a custom link to the Log Call popup.
Similar as Hangout button. I tried to take a look at the Hangout bundle, but view code so complicated…I’m familiar with Symfony, but Oro’s code looks a bit complicated.
So again, how to add a field to Log Call window?Thanks!
- CreatorTopic
- AuthorReplies
- May 27, 2016 at 2:33 am #25207
Hello Alex!
I’m investigating our question.
May 27, 2016 at 4:23 am #25208You should create new form type:
PHP12345678910111213141516<?phpnamespace OroCRM\Bundle\CallBundle\Form\Type;use Symfony\Component\Form\AbstractType;class CallLinkType extends AbstractType{/*** {@inheritdoc}*/public function getName(){return 'orocrm_call_link';}}Register it as service OroCRM/Bundle/CallBundle/Resources/config/form.yml:
YAML123456orocrm_call.call_link.form.type.class: OroCRM\Bundle\CallBundle\Form\Type\CallLinkTypeorocrm_call.call_link.form.type:class: %orocrm_call.call_link.form.type.class%tags:- { name: form.type, alias: orocrm_call_link }Create field html file:
OroCRM/Bundle/CallBundle/Resources/views/Form/fields.html.twig
with
XHTML123{% block orocrm_call_link_widget %}<div id="call_link">This is a <a href="test" rel="nofollow">link</a></div>{% endblock %}Add field to Call Type OroCRM/Bundle/CallBundle/Form/Type/CallType.php
PHP123456789->add('link','orocrm_call_link',['required' => false,'label' => 'orocrm.call.link.label','mapped' => false])add translate to OroCRM/Bundle/CallBundle/Resources/translations/messages.en.yml:
YAML123orocrm:call:link.label: My Linkand include field to Log Call template at first line OroCRM/Bundle/CallBundle/Resources/views/Call/widget/update.html.twig
XHTML1{% form_theme form with ['OroCRMCallBundle:Form:fields.html.twig'] %}Also you can add css to your field:
Create less file: OroCRM/Bundle/CallBundle/Resources/public/css/less/main.less
with
CSS123#call_link {background-color: blue;}Create assets file: OroCRM/Bundle/CallBundle/Resources/config/assets.yml
with
YAML123css:orocrmcall:- 'bundles/orocrmcall/css/less/main.less'And run command: app/console oro:platform:update –force –timeout 9000
May 27, 2016 at 10:54 am #25209If you want add field as customization, use this approach:
Create Custom/Bundle/CallBundle directory in /src
Add custom bundle to app/AppKernel.php in bundle variable:
PHP1new Custom\Bundle\CallBundle\CustomCallBundle()add bundle class src/Custom/Bundle/CallBundle/CustomCallBundle.php
PHP12345678910111213141516<?phpnamespace Custom\Bundle\CallBundle;use Symfony\Component\HttpKernel\Bundle\Bundle;class CustomCallBundle extends Bundle{/*** {@inheritdoc}*/public function getParent(){return 'OroCRMCallBundle';}}add DependencyInjection class src/Custom/Bundle/CallBundle/DependencyInjection/CustomCallExtension.php
PHP123456789101112131415161718192021<?phpnamespace Custom\Bundle\CallBundle\DependencyInjection;use Symfony\Component\DependencyInjection\ContainerBuilder;use Symfony\Component\Config\FileLocator;use Symfony\Component\HttpKernel\DependencyInjection\Extension;use Symfony\Component\DependencyInjection\Loader;class CustomCallExtension extends Extension{/*** {@inheritDoc}*/public function load(array $configs, ContainerBuilder $container){$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));$loader->load('services.yml');$loader->load('form.yml');}}Add form extension src/Custom/Bundle/CallBundle/Form/Extension/CallTypeExtension.php
PHP123456789101112131415161718192021222324252627282930313233<?phpnamespace Custom\Bundle\CallBundle\Form\Extension;use Symfony\Component\Form\FormBuilderInterface;use Symfony\Component\Form\AbstractTypeExtension;class CallTypeExtension extends AbstractTypeExtension{/*** {@inheritdoc}*/public function getExtendedType(){return 'orocrm_call_form';}/*** {@inheritdoc}*/public function buildForm(FormBuilderInterface $builder, array $options){$builder->add('link','custom_call_link',['required' => false,'label' => 'custom.call.link.label','mapped' => false]);}}add custom form src/Custom/Bundle/CallBundle/Form/Type/CallLinkType.php
PHP12345678910111213141516<?phpnamespace Custom\Bundle\CallBundle\Form\Type;use Symfony\Component\Form\AbstractType;class CallLinkType extends AbstractType{/*** {@inheritdoc}*/public function getName(){return 'custom_call_link';}}add src/Custom/Bundle/CallBundle/Resources/config/form.yml
YAML12345678parameters:custom_call.call_link.form.type.class: Custom\Bundle\CallBundle\Form\Type\CallLinkTypeservices:custom_call.call_link.form.type:class: %custom_call.call_link.form.type.class%tags:- { name: form.type, alias: custom_call_link }add src/Custom/Bundle/CallBundle/Resources/config/services.yml
YAML12345678parameters:custom_call.call_form_extension.class: Custom\Bundle\CallBundle\Form\Extension\CallTypeExtensionservices:custom_call.call_form_extension:class: %custom_call.call_form_extension.class%tags:- { name: form.type_extension, alias: orocrm_call_form }add src/Custom/Bundle/CallBundle/Resources/translations/messages.en.yml
YAML123custom:call:link.label: My Linkcopy call log widget template
from vendor/oro/crm/src/OroCRM/Bundle/CallBundle/Resources/views/Call/widget/update.html.twig
to src/Custom/Bundle/CallBundle/Resources/views/Call/widget/update.html.twig
and add this code at first line in copied fileXHTML1{% form_theme form with ['CustomCallBundle:Form:fields.html.twig'] %}add custom html src/Custom/Bundle/CallBundle/Resources/views/Form/fields.html.twig
XHTML123{% block custom_call_link_widget %}This is a <a href="test" rel="nofollow">link</a>{% endblock %} - AuthorReplies
The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.