Custom buttons in entity form
Posted: Thu Jul 02, 2015 4:30 pm
I created a custom entity. I then added a custom button on the entity form by registering it in the entityFormActions.
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).
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.
So that I could easily get the entity ID as a Spring MVC path variable.
What did I do wrong?
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?