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

**URL:** <https://discourse.laminas.dev/t/error-in-zf3-tutorial-using-zend-hydrator-with-zend-form/658>\
**Category:** Components & MVC\
**Created:** [July 26, 2018, 1:04am UTC](https://discourse.laminas.dev/t/error-in-zf3-tutorial-using-zend-hydrator-with-zend-form/658 "2018-07-26T01:04:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tthhorritto](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/tthhorritto/32/355_2.png) [@tthhorritto](https://discourse.laminas.dev/u/tthhorritto)\
**Post date:** [July 26, 2018, 1:04am UTC](https://discourse.laminas.dev/t/error-in-zf3-tutorial-using-zend-hydrator-with-zend-form/658/1 "2018-07-26T01:04:06Z")

</div>

Hi

Everything in the [blog tutorial](https://docs.zendframework.com/tutorials/in-depth-guide/data-binding/) 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;
xdebug_debug_zval('form');
$fieldset = $form->get('post');
xdebug_debug_zval('fieldset');

```

The form debug output shows the data to edit:

```
(refcount=7, is_ref=0)
object(Blog\Form\PostForm)[167]
  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)
        object(Blog\Model\Post)[246]
          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)
object(Blog\Form\PostFieldset)[173]
  protected 'factory' => (refcount=3, is_ref=0)
    object(Zend\Form\Factory)[169]
      protected 'inputFilterFactory' => (refcount=0, is_ref=0)null
      protected 'formElementManager' => (refcount=4, is_ref=0)
        object(Zend\Form\FormElementManager\FormElementManagerV3Polyfill)[60]
          protected 'aliases' => (refcount=1, is_ref=0)
            array (size=72)
              ...
protected 'object' => (refcount=1, is_ref=0)
    object(Blog\Model\Post)[193]
      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?

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [July 26, 2018, 5:20am UTC](https://discourse.laminas.dev/t/error-in-zf3-tutorial-using-zend-hydrator-with-zend-form/658/2 "2018-07-26T05:20:38Z")

</div>

Hi Thorito and welcome to the forum! 😃

> [@tthhorritto](#):
>
> I rechecked the code with the one in the tutorial and is identical.

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

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

```

indicates that something is missing.

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

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

```

> **[Making Use of Forms and Fieldsets - Tutorials - Zend Framework Docs](https://docs.zendframework.com/tutorials/in-depth-guide/zend-form-zend-form-fieldset/#using-zend-hydrator-with-zend-form)**
>
> Learn how to create zend-mvc applications, get in-depth guides into components, and discover how to migrate your applications to version 3!

---

<div class="post-metadata">

**Author:** ![tthhorritto](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/tthhorritto/32/355_2.png) [@tthhorritto](https://discourse.laminas.dev/u/tthhorritto)\
**Post date:** [July 26, 2018, 1:36pm UTC](https://discourse.laminas.dev/t/error-in-zf3-tutorial-using-zend-hydrator-with-zend-form/658/3 "2018-07-26T13:36:13Z")

</div>

Thanks froschdesign

yes i do have that line.

This are the complete debug dump:  
[debug](https://utleonmx-my.sharepoint.com/:u:/g/personal/jmonroy_utleon_edu_mx/EYapf28VjwJOlL68ghopodABRqC4EuaiA-dM5NodM9AHRA?e=KGSejI)

[the code](https://utleonmx-my.sharepoint.com/:u:/g/personal/jmonroy_utleon_edu_mx/EQ8knJLhJkVMjIiMFrM9Lw8B5Pst17VGDG7zbvG-g1PvPQ?e=MAllWS)

---

<div class="post-metadata">

**Author:** ![Greg\_Bell](https://avatars.discourse-cdn.com/v4/letter/g/bcef8e/32.png) [@Greg\_Bell](https://discourse.laminas.dev/u/Greg_Bell)\
**Post date:** [July 30, 2018, 12:53am UTC](https://discourse.laminas.dev/t/error-in-zf3-tutorial-using-zend-hydrator-with-zend-form/658/4 "2018-07-30T00:53:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tthhorritto](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/tthhorritto/32/355_2.png) [@tthhorritto](https://discourse.laminas.dev/u/tthhorritto)\
**Post date:** [August 13, 2018, 8:22pm UTC](https://discourse.laminas.dev/t/error-in-zf3-tutorial-using-zend-hydrator-with-zend-form/658/5 "2018-08-13T20:22:33Z")

</div>

Thanks Greg\_Bell

Here is the [link](https://utleonmx-my.sharepoint.com/:u:/g/personal/jmonroy_utleon_edu_mx/EYlZAzqhMXlPmCC3UdK317sBDRCldpBB-Sz6KLj4-ic5ww?e=xKKiXF) to code.

Better late than never.

---

<div class="post-metadata">

**Author:** ![wantonturnip](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/wantonturnip/32/1129_2.png) [@wantonturnip](https://discourse.laminas.dev/u/wantonturnip)\
**Post date:** [September 22, 2021, 9:37pm UTC](https://discourse.laminas.dev/t/error-in-zf3-tutorial-using-zend-hydrator-with-zend-form/658/6 "2021-09-22T21:37:07Z")

</div>

3 years later, and I’m having the same issue with the laminas tutorial. It’s a long shot, but I’d thought I’d ask if this ever got figured out?

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [September 23, 2021, 7:00am UTC](https://discourse.laminas.dev/t/error-in-zf3-tutorial-using-zend-hydrator-with-zend-form/658/7 "2021-09-23T07:00:30Z")

</div>

> [@wantonturnip](#):
>
> …I’d thought I’d ask if this ever got figured out?

I think @tthhorritto’s problem was that he added the fieldset twice.

Can you show your entire form class?
