How to get the value from an express entity attribute
Permalink
Hey C5 gurus, I'm stuck on this... any advice would be helpful thanks in advance!
Within my C5 8.5.2 installation I have setup 2 express objects, one that has an attribute that is an express entity type (to choose from the other express object).
I setup the forms and can add entries to both object types as expected.
In an express_entry_detail block, I have made a custom block template and I'm trying to get the value from that attribute. I can fetch the object using a magic method as expected, but the object that is retrieved is an "Concrete\Core\Entity\Attribute\Value\Value\ExpressValue Object", and I cannot figure out the method to call to get the info from it. Nothing I try works. I get a 500 server error and if I look at the log the error is
Exception Occurred: /var/www/html/application/blocks/express_entry_detail/templates/Team_Personnel_Grid/view.php:216 Call to undefined method Concrete\Core\Entity\Attribute\Value\Value\ExpressValue::getValuet() (0)
Here's my code....
If I use the plain block with no custom template, it does spit out the data, but I haven't been able to glean how to do this in my custom code.
Help! Thanks in advance!
Within my C5 8.5.2 installation I have setup 2 express objects, one that has an attribute that is an express entity type (to choose from the other express object).
I setup the forms and can add entries to both object types as expected.
In an express_entry_detail block, I have made a custom block template and I'm trying to get the value from that attribute. I can fetch the object using a magic method as expected, but the object that is retrieved is an "Concrete\Core\Entity\Attribute\Value\Value\ExpressValue Object", and I cannot figure out the method to call to get the info from it. Nothing I try works. I get a 500 server error and if I look at the log the error is
Exception Occurred: /var/www/html/application/blocks/express_entry_detail/templates/Team_Personnel_Grid/view.php:216 Call to undefined method Concrete\Core\Entity\Attribute\Value\Value\ExpressValue::getValuet() (0)
Here's my code....
If I use the plain block with no custom template, it does spit out the data, but I haven't been able to glean how to do this in my custom code.
Help! Thanks in advance!
This makes it work...
$tmpStr contains:
Admin Name: John Doe
Member ID: John_Doe [which is a URL to the current page, not sure why]
Short Description: short desc
Long Description: long desc
Thanks to: MrKDilkington athttps://www.concrete5.org/community/forums/customizing_c5/get-expres...
$lsAdminEE = $entity->getAttribute('ls_admin_ee'); // array of Concrete\Core\Entity\Express\Entry $eeArray = $lsAdminEE->getSelectedEntries(); // Concrete\Core\Entity\Express\Entry $thisEE = $eeArray[0]; // array of Concrete\Core\Entity\Attribute\Value\ExpressValue $attributes = $thisEE->getAttributes(); $tmpStr = ''; foreach ($attributes as $attribute) { // Concrete\Core\Entity\Attribute\Value\ExpressValue $tmpStr .= '<p>'.$attribute->getAttributeKey()->getAttributeKeyName() . ': ' . $attribute->getDisplayValue().'</p>'; }
$tmpStr contains:
Admin Name: John Doe
Member ID: John_Doe [which is a URL to the current page, not sure why]
Short Description: short desc
Long Description: long desc
Thanks to: MrKDilkington athttps://www.concrete5.org/community/forums/customizing_c5/get-expres...
I want to join you in asking the community how to use what will be a very useful tool if one or more of the elite developers can tell us how to make it work. Maybe andrew will see this and share his wisdom on how to use/access the data in the Express Entity attribute.
I have received some minimal data back from the Express Entity attribute but something is missing. Here is my story...
I too am using C5v8.5.2
I created an attribute in my Label Set data object of type Express Entity named Admin Express Entity and give it the handle ls_admin_ee
I assign the attribute with handle ls_admin_ee named Admin Express Entity to a row from my Admin data object which has the following four attributes and has all the attributes are populated with data:
Admin Data Object
Name Type Handle Data
---------------------------------------------------------------------------------------------------
Admin Name Text admin_member_name "John Doe"
Member ID User Selector admin_member_id 1
Short Description Text admin_short_desc "short desc"
Long Description Textarea admin_long_desc "long desc"
When retrieving the Express Entity value of a valid row in Label Set from the Admin Express Entity attribute in code I use:
See:https://github.com/concrete5/concrete5/blob/8.5.2/concrete/src/Entit... line 25 $this->selectedEntries = new ArrayCollection(); shows that the data is contained in an object created by executing code to create a new ArrayCollection()
For the one and only row that currently exists in my Label Set I get:
$eeToStr [$ee->__toString()] is set to the value of the first Admin data object attribute “Admin Name” which is “John Doe” but nothing else shows after the value of the first attribute.
But on Dashboard | Express | View Entries | Label Set - for the Label Set data object it shows the Creation date, the Last Modified date the Member name (Select User) John_Doe and the Admin attribute Admin Name which is John Doe (all correct).
$eeCount [count($eeEntries)] is set to 1
print_r($eeEntries,true) returns an error that the memory has been exhausted. I have php.ini memory_limit set to 64MB. Setting it higher does not fix the problem.
How do I access all four attribute values that I am expecting to be in $eeEntries?
If I can’t do a print_r how can I know what the object really contains? var_dump() also exhausts the memory. When I run gettype($eeEntries) it returns “Object”.
Attached is an easier to read PDF.