Hi;
I want to fill dropdown from read_data function which has got Model IDs. Firstly I used Read_Data action but it is getting full a table row like:
[{"Party":{"case_id":"950678196"}}] I don't understand why it shown like this and I tried PHP.
I found some infos in faq and I wrote this code without foreach for test (PS Model ID is party):
<?php
$results=array();
$this->data["party"] = $this->get("read_data3.party");
$results= $this->data["party"]["case_id"];
echo $results;
?>
But this code does not show anyting. What is my mistake in this code?
thx
I want to fill dropdown from read_data function which has got Model IDs. Firstly I used Read_Data action but it is getting full a table row like:
[{"Party":{"case_id":"950678196"}}] I don't understand why it shown like this and I tried PHP.
I found some infos in faq and I wrote this code without foreach for test (PS Model ID is party):
<?php
$results=array();
$this->data["party"] = $this->get("read_data3.party");
$results= $this->data["party"]["case_id"];
echo $results;
?>
But this code does not show anyting. What is my mistake in this code?
thx
$this->data("fieldname")Round brackets: it's a function, not an array.
If you want to SET a data element you need
$this->data("fieldname", "value", true);But I don't see why you would need to do that.
So your PHP code should be
foreach($this->get("read_data3") as $k=>$v) {
echo $v["party"]["case_id"];
}
?>
BUT it actually doesn't need to be either of those. What you need is either
1) Set your read data action to "return an array of key/value pairs" and you can use that as your dropdown values.
or
2) If you absolutely MUST use PHP for whatever reason
$array = array();
foreach($this->get("read_data3") as $row) {
$array[$row["model"]["field_you_want_as_value"]] = $row["model"]["field_you_want_as_label"];
}
return $array;
thank you very much.
This topic is locked and no more replies can be posted.