Field drop-down

  • ducman
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 55
  • Thank you received: 0

ducman created the topic: Field drop-down

Good morning, I've been searching the forum for the following question: is it possible to select the data that is added from a view from a field? that is, I have view1 (field1 = name field2 = country) and view2 (field1 = countries), so that the countries you add in view2-> field1 can be selected in view1-> field2 as a drop-down.

Thank you very much for your help!!
#232098
  • Posts: 1465
  • Karma: 48
  • Thank you received: 194

mihaela replied the topic: Field drop-down

Hello,

I understand what you want to achieve. You would like that what users enter in field2 = country in one View appears as option in select list in field1 = countries in the second View.

It is possible to do so, but it depends on which way you created a View. Did you create a View based on Data Storage or a BreezingForms form?

Regards,

Mihaela
#232112
  • ducman
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 55
  • Thank you received: 0

ducman replied the topic: Field drop-down

Hello Mihaela, I use only ContentBuilder and to create the cells I go to Data Storage.

Thank you!!
#232114
  • Posts: 1465
  • Karma: 48
  • Thank you received: 194

mihaela replied the topic: Field drop-down

Hello again,

Here is how you can populate select list in view 2 with countries entered in textfield in view 1.

Go to the second View (the view that needs to have a select list with countries) and navigate to Editable Prepare tab.

In the code area below paste code similar to this one
$test = "";
$servername = "yourservername";
$username = "yourusername";
$password = "yourpassword";
try {
    $conn1 = new PDO("mysql:host=$servername;dbname=joomla", $username, $password);
    // set the PDO error mode to exception
    $conn1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    // echo "Connected successfully"; 
    foreach($conn1->query('Select country FROM gmb0v_datastoragename ') as $row) {    
        $test .= $row['country'].";".$row['country']."\n";
    }
}
catch(PDOException $e)
    {
     echo "Connection failed: " . $e->getMessage();
    }

try {
    $conn2 = new PDO("mysql:host=$servername;dbname=joomla", $username, $password);
    // set the PDO error mode to exception
    $conn2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    // echo "Connected successfully"; 
    $query = $conn2->prepare("UPDATE gmb0v_contentbuilder_storage_fields SET group_definition = '$test' WHERE id = 54");
    $query->execute(); 
       }
catch(PDOException $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }
NOTE: Here are the changes that you need to make in the code:

1) Set $servername, $username and $password to the correct values for your case.

2) Replace this query 'Select country FROM gmb0v_mystorage ' with the correct query for your case. Replace country with the element's Name in Data Storage where user enters the country. Also, replace mystorage with the name of Data Storage where this element country is.

3) In this line of code:
$test .= $row['country'].";".$row['country']."\n";
replace every instance of country with the element's Name in Data Storage where user enters the country.

4) In this query:
"UPDATE gmb0v_contentbuilder_storage_fields SET group_definition = '$test' WHERE id = 54"
replace 54 with the ID of the select list in second view that you want to fill in with countries.

Let me know whether you have managed to set this so that select list is properly populated.

Regards,

Mihaela
#232119
  • ducman
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 55
  • Thank you received: 0

ducman replied the topic: Field drop-down

Good afternoon Mihaela, sorry I have not answered before, I tried to use the code you provide but it does not work for me, surely I do not know how to put it right.

Sorry you bothered, greetings!
#232219
  • Posts: 1465
  • Karma: 48
  • Thank you received: 194

mihaela replied the topic: Field drop-down

Hello,

Please send me your code so I can take a look at what you might have set wrong.

Regards,

Mihaela
#232245
Moderators: ForumSupporttomeperica
Time to create page: 0.107 seconds

New Support System

Dear Customers,

Users with active subscription have support priority which will be dona via ServiceDesk (My Account > Raise a ticket).
FREE Support topics will be answered when AND if there is time.

You can check support guidelines here : here

Regards,
Crosstec Team

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here