Error in ZF3 Tutorial Using zend-hydrator with zend-form



Everything in the blog tutorial works fine except for the edit action. Accessing the /blog/edit/id it renders the form well but the fields (text and title) display not data to edit.

Debugging Blog/view/blog/write/form.phtml first 5 lines of code:

$form = $this->form;
$fieldset = $form->get('post');

The form debug output shows the data to edit:

(refcount=7, is_ref=0)
  protected 'attributes' => (refcount=1, is_ref=0)
    array (size=3)
      'method' => (refcount=1, is_ref=0)string 'POST' (length=4)
      'name' => (refcount=1, is_ref=0)string 'postform' (length=8)
      'action' => (refcount=1, is_ref=0)string '/is/blog/edit/1' (length=15)
protected 'object' => (refcount=2, is_ref=0)
          private 'id' => (refcount=2, is_ref=0)string '1' (length=1)
          private 'text' => (refcount=2, is_ref=0)string 'Welcome to my first blog post' (length=29)
          private 'title' => (refcount=2, is_ref=0)string 'Blog #1' (length=7)

but the debug output of the fieldset does not:

(refcount=3, is_ref=0)
  protected 'factory' => (refcount=3, is_ref=0)
      protected 'inputFilterFactory' => (refcount=0, is_ref=0)null
      protected 'formElementManager' => (refcount=4, is_ref=0)
          protected 'aliases' => (refcount=1, is_ref=0)
            array (size=72)
protected 'object' => (refcount=1, is_ref=0)
      private 'id' => (refcount=0, is_ref=0)null
      private 'text' => (refcount=1, is_ref=0)string '' (length=0)
      private 'title' => (refcount=1, is_ref=0)string '' (length=0)
  protected 'useAsBaseFieldset' => (refcount=0, is_ref=0)boolean   false

I rechecked the code with the one in the tutorial and is identical.
What could have I missed?


Hi Thorito and welcome to the forum! :smiley:

Can you check the init method of your form class, because this line:

protected 'useAsBaseFieldset' => (refcount=0, is_ref=0)boolean   false

indicates that something is missing.

// In /module/Blog/src/Form/PostForm.php:

public function init()
        'name' => 'post',
        'type' => PostFieldset::class,
        'options' => [
            'use_as_base_fieldset' => true, // Do you have this line?


Thanks froschdesign

yes i do have that line.

This are the complete debug dump:

the code


That’s just the modules. If you include the application dir on down, I’ll run it and have a look…


Thanks Greg_Bell

Here is the link to code.

Better late than never.