ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Save options in the database

rafaelscouto 20 Mar, 2019
Good Morning

I have a form and in it I load the already registered data of a database (load_instruction_imobiliaria_unica).
I intend to use this form to update this data.

In the dropdown (OCUPACAO_DO_LOTE), I load the database with the column I need ({var:carrega_inscricao_imobiliaria_unica.Imo.OCUPACAO_DO_LOTE}).

This option in the database is written as follows:
[CodOCUPACAO_DO_LOTE] => 74
[OCUPACAO_DO_LOTE] => CONSTRUIDO

As per the attached image, I have added more options and would like to know how I can record this in the same way.

For example:

[CodOCUPACAO_DO_LOTE] => 58
[OCUPACAO_DO_LOTE] => CONSTRUÇÃO EM ANDAMENTO

I'm questioning this, because in the way I know, only the data-value that will be the 58

Note: My knowledge in programming / php and database is basic
healyhatman 20 Mar, 2019
OK, thanks for the picture.
Can you explain more though what exactly you're trying to achieve?
rafaelscouto 20 Mar, 2019
I need to save the selected option completely

Ex.

23 = RUÍNAS

Where 23 will be saved in the column (CodOCUPACAO_DO_LOTE)
AND RUÍNAS will be saved in the column (OCUPACAO_DO_LOTE)
healyhatman 20 Mar, 2019
Where are you getting this RUiNAS value from? What does 23 MEAN? Is it an ID of something, in which case you can just store the ID and read the label from a database? Because that's the easiest best option.

Otherwise if you insist on manually entering the option value and label, then you'll need to use a switch (easy) or PHP (harder) to get the label.
rafaelscouto 20 Mar, 2019
I have a "mydb" database

id, name, CodProduct, Product
(1, 'John', 15, 'alpha'),
(2, 'Frank', 23, 'beta'),
(3, 'Marie', 58, 'gamma');
In the dropdown I load the values already in the database (mydb)
I use {var: read_mydb.Model.Product}

I need to give more options at the time of editing, so I added manually

How was my dropdown?

{var: read_mydb.Model.Product}
15 = alpha
23 = beta
58 = gamma

What do I need now?

When selecting an option, save the "CodProduct" and "Product" columns in a new database "mydbnew"

If someone chooses the "gamma" product, save the value 58 in the new "mydbnew" database in the CodProduct column
and save the "range" text also in the new "mydbnew" database in the Product column.

Understood?
healyhatman 20 Mar, 2019
Can you not just add those new options to the database?

And again the way you're doing it, - no, the label isn't sent by the dropdown only the value. That's how select inputs work. So you'd have to use PHP or a switch action to get a different "label" value depending on the dropdown value.
Max_admin 23 Mar, 2019
I need to save the selected option completely
Use a "Switch" action and set it to return the result as var, then use {var:switch_name} in the "Data override" of the "Save data", your switch values should be just like the "dropdown options", but you will use : instead of =

Best regards
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com