+1 571-297-6383 | info@sonjara.com

CompoundSelectFieldRenderer is here to help YOU!

It's been a long while since I've posted an update. This just means that I have a huge number of new Fakoli features to tell you all about. Unfortunately I don't have time right now, so for now I'll just show off the new CompoundSelectFieldRenderer, added in Fakoli 3.2.7.

Often you'll encounter a situation where you have a data item that can be related to one of a number of different data items. You want this to be mutually exclusive when presented in the user interface. In the database you just have a set of foreign keys on the table - you want to be sure that only one is set at a time. If this sounds familiar then CompoundSelectFieldRenderer is the FieldRenderer for you. It provides a grouped select dropdown that enables the user to select just one of the items.

Consider this quick example from our product Griot. In Griot, a task in the task list can be associated with either a Project, a Business Development Opportunity, or a Sales Lead. These three classes are modeled in separate tables, and the task table has foreign key fields called project_id, biz_dev_id and lead_id to maintain the relationships. Using the new CompoundSelectFieldRenderer we can present the selection of these items to the user in a single UI element. The code snippet that sets this up looks like this:

	// Create the Compound select field
	$compoundSelect = new CompoundSelectFieldRenderer($form, "compound_id", "Project, Opportunity or Lead");

	// Query the choices
	$projects = Query::create(Project, "WHERE project_status NOT IN ('Cancelled', 'Completed') ORDER BY project_name")->execute();
	$opportunities = Query::create(Biz_Dev, "WHERE stage NOT IN ('Project Cancelled', 'Lost Bid', 'Awarded') ORDER BY project_name")->execute();
	$salesLeads = Query::create(SalesLead, "WHERE active=1 AND relationship != 'Do Not Contact' ORDER BY last_name, first_name")->execute();

	// Add them to the control

	$compoundSelect->add("Projects", "project_id", $projects, "{project_name}");
	$compoundSelect->add("Opportunities", "biz_dev_id", $opportunities, "{project_name}");
	$compoundSelect->add("Sales Lead", "lead_id", $salesLeads, "{formatName()}");

And AutoForm will take care of the rest for you.

Obviously you can add validators as you need them, using the usual AutoForm facilities. As you can see, this is an easy and elegant solution to a fairly common piece of UI that often leads to database inconsistencies or unhappy users. Enjoy!


Be the Monarch of all you Survey » « Improve download performance with mod_xsendfile
 

Comments

  • a0ycmb2w
    Posted by MichaelDrola at 2017-09-29 22:29:44
    wh0cd860504 ampicillin sulbactam ampicillin sulbactam http://ampicillinsulbactam.us.com/ mebendazole medication mebendazole http://mebendazole.us.com/
* indicates required field