Forums › Forums › OroPlatform › OroPlatform – How do I? Questions › Add button with confirmation message
This topic contains 4 replies, has 2 voices, and was last updated by jneto 7 years, 4 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- November 28, 2016 at 5:39 am #36402
Can I add a button with a confirmation message like the delete button without using JavaScript ?
- CreatorTopic
- AuthorReplies
- December 1, 2016 at 2:43 am #36403
Hi
Are we talking about these grid buttons ? If no, please show me your button.
December 1, 2016 at 10:44 am #36404In the view.html.twig of my entity, i need to use the UI.button and/or UI.dropdownItem
PHP12345{{ UI.dropdownItem({'path': path('notification_send_email', {id:entity.id}),'title': 'Send Email','label': 'Send Email'}) }}but i need to send a confirmation message, in case the user click the button by mistake.
Thanks
December 2, 2016 at 2:41 am #36405Hi
Here is my example, if you want, you can make it better:
XHTML123456789101112{{ UI.button({'path' : path('oro_calendar_event_index'),'iCss': 'icon-time','label': 'oro.calendar.view_events'|trans,'title': 'oro.calendar.view_events'|trans,'confirmation': {id: 'test_button',content: 'Are you sure?',ok: 'Submit',cancel: 'Cancel'}}) }}Add this IF to the end of link macros:
XHTML1234567891011121314151617181920212223{% if parameters.confirmation is defined %}<script type="text/javascript">require(['jquery', 'orotranslation/js/translator', 'oroui/js/delete-confirmation', 'oroui/js/mediator'],function ($, __, confirmation, mediator) {$(document).ready(function () {$('#{{ parameters.confirmation.id }}').on('click', function () {var confirm = new confirmation({content: __('{{ parameters.confirmation.content }}'),okText: __('{{ parameters.confirmation.ok }}'),cancelText: __('{{ parameters.confirmation.cancel }}')});confirm.on('ok', _.bind(function () {mediator.execute('redirectTo', {url: '{{ parameters.path }}'}, {redirect: true});}, this));confirm.open();return false;});});});</script>{% endif %}December 2, 2016 at 11:57 am #36406Thanks. I will try it.
My idea was not using custom JavaScript. I read the actionbundle documentation and I was hoping that the confirmation message could be achieved with configuration of the ui button macro call.
- AuthorReplies
The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.