How do I get the element name in PHP?

rrwilson

Member
Hello all

I am customising an element's layout in the list and form files, and I am wondering how I can access the element name in PHP (I am meaning the unique element name , rather than the label)

Many thanks :)
 
I see other things, but this seems so obvious am obviously not searching for the correct terms when I am searching the forum with google :(
 
hi there :), thanks, but that's not it for me....

I had already been there, but i couldn't find what i need. it doesn't refer to accessing the current element name:
  • it only refers to label and data, not name
  • the examples also depend on specifying the table and element name, which is ironic for me as the name is actually want I want to lookup programatically for the current row being generated
:(
 
Last edited:
Well, you can always do a var_dump or print_r to see the structure of arrays and objects depending on list or details/form, where the element and eventually group names as set by you when creating them are keys.
 
Yup, I had done that too with several vars :(

I know that I must be missing something that is stupidly obvious... :confused:
 
Ah, I see the issue now, I missed the bit about it being a layout. When working with layouts (as opposed to things like form plugins or templates), the only data you have access to is what is passed in to the layout in $displayData (usually shortened to $d). And in the case of the thumbs layouts, that doesn't include anything that would give you access to the element model.

Looking at the code though, we do actually pass in the full element name, in $d->name.

I've also just added the element model itself, as $d->elementModel, so you could do things like $d->elementModel->getElement()->name.

https://github.com/Fabrik/fabrik/commit/75c9a383f60195d1ee2ea1bd9a09cd95f9966b78

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top