# Baked Edit not working

**URL:** <https://discourse.cakephp.org/t/baked-edit-not-working/4911>\
**Category:** Need Help\
**Created:** [September 12, 2018, 9:58am UTC](https://discourse.cakephp.org/t/baked-edit-not-working/4911 "2018-09-12T09:58:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavsnellski](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@pavsnellski](https://discourse.cakephp.org/u/pavsnellski)\
**Post date:** [September 12, 2018, 9:58am UTC](https://discourse.cakephp.org/t/baked-edit-not-working/4911/1 "2018-09-12T09:58:23Z")

</div>

Hi

I have been using cakephp for a long time, but use it at a fairly basic level.

I have a table - called UserBaskets (which has associations with Users and UserBasketItems).

I have baked the CRUD controller and templates.

Here is the Edit method from the UserBasketController

```
    public function edit($id = null)
    {
        $userBasket = $this->UserBaskets->get($id, [
            'contain' => []
        ]);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $userBasket = $this->UserBaskets->patchEntity($userBasket, $this->request->getData());
            if ($this->UserBaskets->save($userBasket)) {
                $this->Flash->success(__('The user basket has been saved.'));

                return $this->redirect(['action' => 'index']);
            }
            $this->Flash->error(__('The user basket could not be saved. Please, try again.'));
        }
        $users = $this->UserBaskets->Users->find('list', ['limit' => 200]);
        $basketStatuses = $this->UserBaskets->BasketStatuses->find('list', ['limit' => 200]);
        $this->set(compact('userBasket', 'users', 'basketStatuses'));
    }

```

And here is the Edit template for that controller:

```
<?php
/**
 * @var \App\View\AppView $this
 * @var \App\Model\Entity\UserBasket $userBasket
 */
?>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
    <ul class="side-nav">
        <li class="heading"><?= __('Actions') ?></li>
        <li><?= $this->Form->postLink(
                __('Delete'),
                ['action' => 'delete', $userBasket->ID],
                ['confirm' => __('Are you sure you want to delete # {0}?', $userBasket->ID)]
            )
        ?></li>
        <li><?= $this->Html->link(__('List User Baskets'), ['action' => 'index']) ?></li>
        <li><?= $this->Html->link(__('List Users'), ['controller' => 'Users', 'action' => 'index']) ?></li>
        <li><?= $this->Html->link(__('New User'), ['controller' => 'Users', 'action' => 'add']) ?></li>
        <li><?= $this->Html->link(__('List Basket Statuses'), ['controller' => 'BasketStatuses', 'action' => 'index']) ?></li>
        <li><?= $this->Html->link(__('New Basket Status'), ['controller' => 'BasketStatuses', 'action' => 'add']) ?></li>
        <li><?= $this->Html->link(__('List User Basket Items'), ['controller' => 'UserBasketItems', 'action' => 'index']) ?></li>
        <li><?= $this->Html->link(__('New User Basket Item'), ['controller' => 'UserBasketItems', 'action' => 'add']) ?></li>
    </ul>
</nav>
<div class="userBaskets form large-9 medium-8 columns content">
    <?= $this->Form->create($userBasket) ?>
    <fieldset>
        <legend><?= __('Edit User Basket') ?></legend>
        <?php
            echo $this->Form->control('user_id', ['options' => $users]);
            echo $this->Form->control('basket_name');
            echo $this->Form->control('basket_status_id', ['options' => $basketStatuses, 'empty' => true]);
        ?>
    </fieldset>
    <?= $this->Form->button(__('Submit')) ?>
    <?= $this->Form->end() ?>
</div>

```

This is all straight out of bake.  
When I try to update the basket\_status\_id using the above template, no error is reported, and the success Flash message is shown.

BUT, and this is the infuriating bit - the actual basket’s basket\_status\_id is NOT updated, it remains the same.

No errors, nothing. And I am not sure how to track this problem.

Any suggestions or similar experiences would be welcome!

Thanks

---

<div class="post-metadata">

**Author:** ![Graziel](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Graziel](https://discourse.cakephp.org/u/Graziel)\
**Post date:** [September 12, 2018, 1:17pm UTC](https://discourse.cakephp.org/t/baked-edit-not-working/4911/2 "2018-09-12T13:17:09Z")

</div>

check `_accessible` in `UserBasket` entity in `App\Model\Entity`

---

<div class="post-metadata">

**Author:** ![pavsnellski](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@pavsnellski](https://discourse.cakephp.org/u/pavsnellski)\
**Post date:** [September 12, 2018, 1:21pm UTC](https://discourse.cakephp.org/t/baked-edit-not-working/4911/3 "2018-09-12T13:21:56Z")

</div>

Brilliant, many thanks Graziel - I had added the basket\_status\_id field after having baked the models. New to version 3, so missed that out. It is working beautifully now!
