Field datasource with conditional March 10, 2019, 07:14:08 PM We know that for simple structures like country/province/city where each of the children can only belong to a parent, we can link multiple select fieldss using the field datasource (OptionListDatasource) in Add/Edit pages. And it works really well, allowing to link several select fields to display only the values that belong to the previously selected parent.But.. would it be possible to have a slightly more complex selection. This is the scenario.* Country tableid, countryname* Seller tableid, sellername* Brandid, brandname, idseller, idcountry* Productid, productname, idseller, idbrand, idcountry (and whatever else you want to add after)So the intention is to be able to create a page to ADD products and follow this logic using select fields.1. Select the Country2. Select the Seller3. Select the Brand (displaying only the brands matching the previous to selections for idseller and idcountry)Things get complicated when a seller can sell in more than one country, and when a seller can sell the same brand in more than one country.My goal is to figure if something like this is doable with current PHPRad tools, maybe with query parms, as I see something like this $lookup_country is added to query params in the case of simple scenarios. Would be possible to add 2 and make the query more complex? Quote Selected
Re: Field datasource with conditional Reply #1 – June 17, 2019, 02:59:52 PM Hi, Do you have any solution for this :My goal is to figure if something like this is doable with current PHPRad tools, maybe with query parms, as I see something like this $lookup_country is added to query params in the case of simple scenarios. Would be possible to add 2 and make the query more complex Quote Selected
Re: Field datasource with conditional Reply #2 – June 17, 2019, 08:40:51 PM Complex select with the option field might not be possible for the moment. But you can use the "Edit query button" to ediy sql query. Quote Selected
Re: Field datasource with conditional Reply #3 – June 18, 2019, 10:32:16 AM This is a good exercise. Are all brands available in each country ? Quote Selected
Re: Field datasource with conditional Reply #4 – June 21, 2019, 02:02:15 AM but, how i can build a query where clause with two fields values Quote Selected
Re: Field datasource with conditional Reply #5 – June 25, 2019, 12:32:29 PM @jfgonzalez You can have a query like this"SELECT COUNT(*) AS num FROM contact where name = ? OR name = ?" and query params'Williams Akor','John Smith'or"SELECT COUNT(*) AS num FROM contact where name = ? AND name = ? AND name = ?" and query params'Williams Akor','John Smith','John Doe'The important thing is, no matter how complex your query is, remember to add the correct number of values or variables to bind to the query separated by comas. Quote Selected