abmcr Posted January 31, 2018 Posted January 31, 2018 I have a field FileType named allegato into a repeater named documenti I want to retrieve the value of the field allegato for all pages for creating a custom field module; Into the module i have this code foreach($output->documenti as $item) { echo "PRINT ALLEGATO"; var_dump($item->allegato); echo "PRINT ALLEGATO -> count"; //this line echo the count as 1 var_dump($item->allegato->count); echo "PRINT ALLEGATO -> items"; /(/this line get NULL.... WHY? var_dump($item->allegato->items); echo "PRINT ALLEGATO -> url"; var_dump($item->allegato->url); // this line get me the url ... without the name of the file ???? echo "PRINT ALLEGATO -> description"; var_dump($item->allegato->description); //this line get me null though the value exist in the table (see image below) The result is where i show only one row (id 2003). Why i am not able to retrieve the value of $object->items?? And why $item->allegato->url show a partials url of the attachment and $item->allegato->description print null??? the same code into a single template work fine and output the correct values Thank you in advance
adrian Posted January 31, 2018 Posted January 31, 2018 File fields are an array (unless you set maxFiles to 1), so you need to either foreach or first(), last() or eq(n) to get a specific file. $item->allegato->first()->url; There is no "items" property, hence the NULL. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now