Page 1 of 2

Custom buttons in entity form

Posted: Thu Jul 02, 2015 4:30 pm
by mercury1231
I created a custom entity. I then added a custom button on the entity form by registering it in the entityFormActions.

Code: Select all

       
// add tracking record button
EntityFormAction efa = new EntityFormAction("Add Tracking")
                .withDisplayText("Add Tracking")
                //.withIconClass("icon-plus")
                .withButtonClass("custom-modal-form")
                .withUrlPostfix("/tracking/add");

entityForm.addAction(efa);


And I also created a new javascript file to handle this new button behavior "custom-modal-form". Basically what I want to do is something similar to a "update" or "delete" operation but it will show a custom modal form first (to let the admin user to enter admin information, and then click on save or submit button on this modal form).

Code: Select all

$(document).ready(function() {
    $('body').on('click', 'button.custom-modal-form', function(event) {
        var link = $(this).data('url');
        //var link = $(this).data('action');
       BLCAdmin.showLinkAsModal(link);
       return false;
    });
});


You can see that in the above javascript I commented out the second line in the body. The weird behavior is, assuming the entity form url is "http://abc.com/entity/1002" where 1002 is the entity ID. If getting the link by "url" property, then the final URL that BLC is trying to retrieve for this custom modal form becomes "http://abc.com/entity/entity/tracking/add", while when I get the link by "action" property, the final URL becomes "http://abc.com/tracking/add". Either way it's incorrect. I want the final URL to look like this one below.

Code: Select all

http://abc.com/entity/1002/tracking/add


So that I could easily get the entity ID as a Spring MVC path variable.

What did I do wrong?

Re: Custom buttons in entity form

Posted: Sun Jul 05, 2015 11:55 pm
by phillipuniverse
This functionality was added in Broadleaf 4.0.0-GA+: https://github.com/broadleafcommerce/br ... 07ff79c927.

It basically allows you to invoke withUrlOverride().

Re: Custom buttons in entity form

Posted: Tue Aug 04, 2015 2:10 pm
by mercury1231
After an attempt to upgrade to 4.0.0, I realized that it's taking more efforts than I expected. I had quite a bit of custom code relying on 3.0. Is there a way to make this work on 3.0 code base?

Re: Custom buttons in entity form

Posted: Thu Nov 19, 2015 1:22 am
by shrutigoel57
Hi All,

I am new to broadleaf.
I wnat to add a new button on entity form.button is added using entity form action.but I am not able to invoke the request mapping on this button.kindly help if anyone has done it.