Selecting list values for another list

  • Bibbp
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 40
  • Thank you received: 0

Bibbp replied the topic: Selecting list values for another list

Hi Mihaela,

I have a data store for a list of residents in a housing association. I have a view over that data store to view the data, but also to add/modify/and delete. Many of the items of data have simple Yes/No values, and for these I can use the group values process. But for others the range of possible values can change, eg Town. there is no way I can set up every Town in the group values, so there appear to be two possible approaches:
1) Create a method whereby I can enable a special user to add any new Town to the group list (without signing on to the back end), or
2) Create a data store of Towns and let the view of Residents retrieve the Town from a view over the Town data store.

I don't mind which it is. What do you advise?

Many thanks

Peter
#234748
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 1938
  • Karma: 67
  • Thank you received: 234

mihaela replied the topic: Selecting list values for another list

Ok, now I understand how this is supposed to work.

It seems that in your case the simplest solution would be to use "Text" field instead of an element with possible cities to choose from.

Would that be acceptable for you?

The other solution would be as you wrote in 2). You could create a new Data Storage with a field named town and a View based on that Data Storage. Using the code form the link I've previously sent the "select list" of towns in the old view will be filled with towns submitted in that new view. There when you would click on NEW and submit record with new town it would be added to the select list in old element.

Regards,

Mihaela
#234754
  • Bibbp
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 40
  • Thank you received: 0

Bibbp replied the topic: Selecting list values for another list

Hi Mihaela

I must be so close, but I'm not getting data in the select box...
Here is my code in Editable Prepare, which is not throwing an exception...
(Is localhost ok for the server name?)

$test = "";
$servername = "localhost";
$username = "shameabo_rockusr";
$password = "BJ04ume135";
try {
$conn1 = new PDO("mysql:host=$servername;dbname=shameabo_rock", $username, $password);
// set the PDO error mode to exception
$conn1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// echo "Connected successfully";
foreach($conn1->query('Select Town FROM ogt9s_town ') as $row) {
$test .= $row.";".$row."\n";
}
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}

try {
$conn2 = new PDO("mysql:host=$servername;dbname=shameabo_rock", $username, $password);
// set the PDO error mode to exception
$conn2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// echo "Connected successfully";
$query = $conn2->prepare("UPDATE ogt9s_contentbuilder_storage_fields SET group_definition = '$test' WHERE id = 26");
$query->execute();
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}

Any ideas?

Many thanks

Peter
#234791
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 1938
  • Karma: 67
  • Thank you received: 234

mihaela replied the topic: Selecting list values for another list

Hello,

I'm looking at your code, but I am not sure where is the error.

As for the localhost if you are testing it on localhost then it is ok.

This is the code that I am using which is working fine:
// Here you may alter labels and values for each item before it gets rendered through your editable template.
// For example:
// $items["ITEMNAME"]["value"] = $items["ITEMNAME"]["value"];
// $items["ITEMNAME"]["label"] = "<i>".$items["ITEMNAME"]["label"]."</i>";

$test = "";
$servername = "localhost";
$username = "root";
$password = "";
try {
    $conn1 = new PDO("mysql:host=$servername;dbname=joomladva", $username, $password);
    // set the PDO error mode to exception
    $conn1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    // echo "Connected successfully"; 
    foreach($conn1->query('Select field1 FROM ns62f_storagone') as $row) {    
        $test .= $row['field1'].";".$row['field1']."\n";
    }
}
catch(PDOException $e)
    {
     echo "Connection failed: " . $e->getMessage();
    }

try {
    $conn2 = new PDO("mysql:host=$servername;dbname=joomladva", $username, $password);
    // set the PDO error mode to exception
    $conn2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    // echo "Connected successfully"; 
    $query = $conn2->prepare("UPDATE ns62f_contentbuilder_storage_fields SET group_definition = '$test' WHERE id = 25");
    $query->execute(); 
       }
catch(PDOException $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }

Also, is "shameabo_rock" name of Joomla databse in your case?

Regards,

Mihaela
#234821
Moderators: ForumSupporttomeperica
Time to create page: 0.069 seconds

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