Hello GroceryCRUD Enterprise community,
I’m experiencing an issue with my GroceryCRUD Enterprise implementation (version 3.1.16) in a CodeIgniter 4 project. When trying to access the edit form, I’m getting the following error:
Call to undefined method GroceryCrud\Core\State\EditFormState::setRelation1to1Fields()
Error details
The error occurs in /var/www/html/certificacion_daf/vendor/grocery-crud/enterprise/src/GroceryCrud/Core/State/EditFormState.php
on line 79, where it’s trying to call the setRelation1to1Fields()
method:
php
$outputData = $this->setRelation1to1Fields($outputData);
Problem analysis
The interesting thing is that the setRelation1to1Fields()
method is actually defined in the parent class StateAbstract
, but for some reason, it’s not being recognized when called from EditFormState
.
I’ve examined both classes, and EditFormState
extends StateAbstract
correctly:
php
class EditFormState extends StateAbstract {
The setRelation1to1Fields()
method is defined in StateAbstract.php
(I’ve verified this), but when the code execution reaches the call in EditFormState
, PHP throws the undefined method error.
My environment
- CodeIgniter 4
- PHP 8.1
- GroceryCRUD Enterprise 3.1.16
- I recently upgraded from version 3.1.4 to 3.1.16
My implementation
Here’s my simple controller method:
php
public function personaDaf()
{
$crud = $this->templater->_getGroceryCrudEnterprise();
$crud->setCsrfTokenName(csrf_token());
$crud->setCsrfTokenValue(csrf_hash());
$crud->setTable('persona_daf');
$output = $crud->render();
return $this->templater->_grocerycrud_output($output);
}
Attempted solutions
- Tried updating via Composer:
composer update grocery-crud/enterprise --with-dependencies
- Tried requiring the specific version:
composer require "grocery-crud/enterprise:^3.1.16" --prefer-dist
- Cleared Composer cache and updated again
None of these solutions resolved the issue. I’m avoiding modifying vendor files directly since that’s not a sustainable solution.
Has anyone experienced a similar issue? Any suggestions on how to resolve this without modifying the vendor files? Perhaps using the replaceState()
method to override the EditFormState
class?