0
votes

I am experiencing some issues when trying to generate a form using 'inputs'

<?php 
  echo $this->Form->create('Post');
  echo $this->Form->inputs(array( 'legend' => 'Personal information', 'name', 'nickname', 'age', 'email')); 
  echo $this->Form->inputs(array( 'legend' => 'Employment information', 'company', 'started_work', 'description')); 
?>

Output: Warning (2): array_keys() expects parameter 1 to be array, null given [CORE\Cake\View\Helper\FormHelper.php, line 848]

When i remove $this->Form->create('Post'); it generates succesfully, but it does not have the output...

1
You could try just creating your field set manually with regular HTML, and then creating your inputs one by one with cake form helpers 'input' method. - joshua.paling

1 Answers

1
votes

Have you double-triple-checked that:
a) your Post.php model exists and is named correctly
b) your posts table exists in your database
c) your app is connecting to the database OK?

The error is coming when the FormHelper calls the '_introspectModel' method, and returns null. The _introspectModel method is supposed to return info about the fields in the model and so on. But, if it can't retrieve the information it needs from the model, then it'll return null rather than an array. So that's what's causing the error you're getting.

Double check everything related to your Post model, and if you still can't fix the error, update your question and paste the code from your Post model.