Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1704

Joomla! 4.x Coding • J4.0 view requires entity to exist - what's changed?

$
0
0
I'm finishing off porting a component from J3.10 to J4.4 and have encountered a strange issue with all my entities.

In J3.10, editing an existing entity resulted in $this->item in the edit template being fully populated. I never really figured out this magic in over a decade of working with Joomla, but broadly it seems that the following takes place:

the view calls $this->get('Form')
getForm() in the model is called with loadData = true,
loadForm() in the model is called
getItem() in the model loads the data for the entity into $this->item
The populated form is displayed in the template, data shown with renderField()

When a new entity is added $this->item is null, so the default values in entity.xml are displayed.

Here's the problem: in J4.0 I get a whole bunch of "Warning: Undefined property: stdClass::xxx ..." errors because $this->item is null.

What's changed? It seems that getItem() is not called in J3.10 when adding a new item but it is in J4.4.

Do I need to hack up some sort of dummy entity to be displayed? Or is it just a bug?

Any help would be great :(

Statistics: Posted by david0058 — Mon Mar 03, 2025 10:41 am



Viewing all articles
Browse latest Browse all 1704

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>