In Joomla 2.5, how can I do a form field type "SQL" with the condition "WHERE" in the SQL query?
Example:
<field name="catid" type="sql" query="SELECT id, title FROM #__table WHERE {condition}" />
There isn't anything about this in the joomla docs. I've found this link but it doesn't refer anything of using a WHERE condition in the SQL query ( http://docs.joomla.org/SQL_form_field_type).
Can someone please tell me if this is possible or not to do in Joomla?
I have a table with products and a table with shops associated to brands. If I edit one shop I would like to show a combobox with all the products from the brand of the shop. Is that possible? SELECT * FROM #__products WHERE brand = {the brand id associated to the shop I selected for edit} Is this possible?
I was able to do this with a custom form field =)
http://docs.joomla.org/Creating_a_custom_form_field_type
Thank you RHR for your answer !
Here's my solution:
You can replace the query completely by doing the following:
1)Define you query:
$query = 'SELECT * from table_name WHERE table_id = '.$your_value;
2)Update your form field attribute:
$this->form->setFieldAttribute('field_name', 'query', $query);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With