Preventing removal of list field data

2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 9, 2014   (RSS)

By pault - September 9, 2014

I have a table (for products) in CMS Builder which has in it a list field populated by another table (for categories) in the CMS. 

I'd like to offer the user the facility to delete categories if they wish, but prevent this from happening if the category is already selected on one of the product records.

Can you let me know if this is possible please?

Thanks.

By claire - September 9, 2014

Hi there,

What you're talking about is custom code, but the general jist of it would go like this:

  • The user sends a request to delete a category.
  • The system does a mysql count query against all products, looking for those with the category ID selected.
  • If the count > 0, return an error and prevent the deletion.
  • If the count = 0, accept the request and go ahead with the deletion.

It's very possible, of course, but I don't think we've got any code snippets to do it offhand. If you'd like us to code it for you, you can email consulting@interactivetools.com and we'll get you sorted out.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/