Hello,
i am trying to finish the Blog Tutorial of the CakePHP 4.x Strawberry Cookbook.
Unfortunately i am getting an SQLSTATE[HY000]: General error: 1364 Field ‘category_id’ doesn’t have a default value.
I am at Blog Tutorial - Part 3 right now, but unlike the Tutorials suggests me it is impossible to remove the following controls in the Categories add and edit template files because they do not exist:
echo $this->Form->control(‘lft’);
echo $this->Form->control(‘rght’);
Also it is not possible to disable or remove the requirePresence from the validator for both the lft and rght columns in your CategoriesTable mode because both validators dont exist in the file but I added them:
public function validationDefault(Validator $validator): Validator
{
$validator
->add(‘id’, ‘valid’, [‘rule’ => ‘numeric’])
->allowEmptyString(‘id’, ‘create’);
$validator
->add('lft', 'valid', ['rule' => 'numeric'])
// ->requirePresence('lft', 'create')
->notEmpty('lft');
$validator
->add('rght', 'valid', ['rule' => 'numeric'])
// ->requirePresence('rght', 'create')
->notEmpty('rght');
}
Thank you for helping!