Admin Edit View: item.id not populated in Model state — edit form loads empty #1025
Unanswered
mehdisabbagh
asked this question in
Extention Issues
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Environment
itemProblem
This problem happens only if I create an ID field in an ADMIN VIEW. I prefere to do this to put the ID field anywhere in the admin view.
When clicking "Edit" on an item in the backend list view, the edit form opens
but all fields are empty. The URL is:
index.php?option=com_puyaclassifieds&view=item&layout=edit
Note: the
idparameter is missing from the URL.Root Cause Analysis
Tracing the call stack:
HtmlView::display()calls$this->form = $this->get('Form')ItemModel::getForm()→loadForm()→loadFormData()loadFormData()calls$this->getItem()with no$pkgetItem(null)callsparent::getItem(null)AdminModel(parent) readsitem.idfrom internal stateitem.idis never set → returns empty objectThe generated
ItemModel.phphas nopopulateState()override.AdminModel::populateState()is expected to readidfrom jinput/request,but this does not appear to happen correctly in the current generated code.
Generated Code (relevant excerpt)
Question
populateState()readsidfrom the request so it survives component rebuilds?
settings intended for
populateState?idbe passed via URL, viatask, or via a hidden form field?All reactions