Skip to content

HasOne nested key #4486

@aqjw

Description

@aqjw
  • Laravel Version: 9.11
  • Nova Version: 4.10.0
  • PHP Version: 8.1.3

Description:

HasOne does not support nested keys.
As a result, it is not possible to read the value on the server-side.

Screenshot 2022-06-27 at 13 32 16

The keys are generated in the file resources/js/fields/Form/HasOneField.vue, but there is no nesting check here.

Screenshot 2022-06-27 at 14 31 39

Solution

Screenshot 2022-06-27 at 14 32 20

entries.forEach((data, attribute) => {
  var attribute_key = `[${attribute}]`

  if (attribute.includes('[')) {
    let pos = attribute.indexOf('[')
    let key = attribute.substr(0, pos)
    let nested = attribute.substr(pos)
    attribute_key = `[${key}]${nested}` 
  }

  this.fillIfVisible(
    formData,
    this.field.attribute+attribute_key,
    data || ''
  )
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions