# Bug on checkboxes form

**URL:** <https://community.forestadmin.com/t/bug-on-checkboxes-form/6707>\
**Category:** Help me!\
**Created:** [September 29, 2023, 1:35pm UTC](https://community.forestadmin.com/t/bug-on-checkboxes-form/6707 "2023-09-29T13:35:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LouisLoode](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louisloode/32/5960_2.png) [@LouisLoode](https://community.forestadmin.com/u/LouisLoode)\
**Post date:** [September 29, 2023, 1:35pm UTC](https://community.forestadmin.com/t/bug-on-checkboxes-form/6707/1 "2023-09-29T13:35:58Z")

</div>

Since this morning, when we want to add some string in text array, the array is always empty.

## Feature(s) impacted

Forms with checkboxes

## Observed behavior

 ![Capture d’écran 2023-09-29 à 15.35.24](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/9/9ea7c9a173fb68ec121438566588549b63d9e78a.png)

My entity:

```javascript
const { v4: uuidv4 } = require('uuid');
const isEmpty = require('lodash/isEmpty');

// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models

module.exports = (mongoose, Mongoose) => {
  // This section contains the properties of your model, mapped to your collection's properties.
  const schema = Mongoose.Schema(
    {
      name: {
        type: String,
        required: true,
      },
      logo: {
        type: String,
      },
      type: {
        type: String,
        required: true,
        default: 'corporation',
      },
      siret: {
        type: String,
      },
      domain: {
        type: String,
        match: [/\.intent$/, 'Invalid domain'],
        required: true,
        immutable: true,
        unique: true,
      },
      entityRoles: [
        {
          _id: false,
          name: String,
        },
      ],
      stringifiedRoles: {
        type: String,
      },
      activated: {
        type: Boolean,
      },
      settings: {
        type: JSON,
      },
    },
    {
      timestamps: { createdAt: 'creationDate', updatedAt: 'lastUpdateDate' },
      versionKey: false, // You should be aware of the outcome after set to false
    },
  );

  schema.pre('save', async function () {
    if (isEmpty(this.logo)) {
      this.logo = `${process.env.BASE_LOGO_URL}${uuidv4()}.png`;
    }

    console.log('this', JSON.stringify(this));
    console.log('this.entityRoles', JSON.stringify(this.entityRoles));
    if (this.entityRoles) {
      _hasAssetOwnerAndServiceProviderRoles(this.entityRoles);
    }
  });

  schema.pre('findOneAndUpdate', function (next) {
    const { $set } = this._update;
    console.log('this._update', JSON.stringify(this._update));
    if ($set.entityRoles) {
      _hasAssetOwnerAndServiceProviderRoles($set.entityRoles);
    }

    next();
  });

  return mongoose.model('entities', schema, 'entities');
};

/**
 * Check if there is assetOwner and serviceProvider in entityRoles
 * @param {Object[]} entityRoles - the entityRoles
 * @returns {boolean} - true|false
 */
function _hasAssetOwnerAndServiceProviderRoles(entityRoles) {
  console.log('entityRoles', JSON.stringify(entityRoles));
  if (
    entityRoles.some((role) => role.name === 'assetOwner') &&
    entityRoles.some((role) => role.name === 'serviceProvider')
  ) {
    throw new Error(
      'Vous ne pouvez pas définir un rôle "assetOwner" et un rôle "serviceProvider" pour une entité.',
    );
  }

  if (entityRoles.length === 0) {
    throw new Error('Vous devez forçément définir un rôle pour une entité.');
  }

  return true;
}

```

## Expected behavior

Have an array of string (it worked this morning since multiple weeks ^^)

## Failure Logs

 ![Capture d’écran 2023-09-29 à 15.32.31](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/1/18ade688f13e928a47e9830e1a4a6a85001aa07a.png)  
 ![Capture d’écran 2023-09-29 à 15.34.27](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/e/eac7307ce6288a08392b14322fb947799e5ac30c.png)

## Context

- Project name: intent
- Environment name: Production and Sandbox
- Agent (forest package) name & version: “forest-express-mongoose”: “^9.2.4”
- Database type: Mongodb
- Recent changes made on your end if any: Nothing

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [September 29, 2023, 2:03pm UTC](https://community.forestadmin.com/t/bug-on-checkboxes-form/6707/2 "2023-09-29T14:03:53Z")

</div>

Hello @LouisLoode

Thanks a lot for reaching us with this issue. We’ve identified the origin and a rollback is in progress.

I’ll keep you posted.

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [September 29, 2023, 2:07pm UTC](https://community.forestadmin.com/t/bug-on-checkboxes-form/6707/4 "2023-09-29T14:07:08Z")

</div>

The rollback has been made. Can you try the same operation after refreshing your browser?

---

<div class="post-metadata">

**Author:** ![LouisLoode](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louisloode/32/5960_2.png) [@LouisLoode](https://community.forestadmin.com/u/LouisLoode)\
**Post date:** [September 29, 2023, 2:10pm UTC](https://community.forestadmin.com/t/bug-on-checkboxes-form/6707/5 "2023-09-29T14:10:10Z")

</div>

It seems to be ok, thank you for your responsiveness.
