Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

4unkur's avatar

Fill custom field's value on edit page

I have created custom field in Nova and cannot figure it out: How can I handle the value of the field on the edit page? By default Nova provides you the value of the field in Vue, but my field is a list of many to many self referencing relationships.

You can see: https://imgur.com/Nh7Loxm

Also, how can I show this field only on edit page and hide on add page?

0 likes
2 replies
4unkur's avatar
4unkur
OP
Best Answer
Level 3

Nova is damn good. It's already loading all the dependencies so I just looped through the values:

 setInitialValue() {
    if (this.field.value.length) {
        this.field.value.forEach((alias) => {
            this.aliases.push(alias.name)
            this.values.push(alias.pivot.alias_id) // here is the actual value from pivot table
        })
    }
},

About hiding the field on edit page:

https://nova.laravel.com/docs/1.0/resources/fields.html#showing-hiding-fields

1 like
keizah7's avatar
ModelFill::make(__('Prekės'), 'products')
    ->fields([
        'no' => [
            'label' => 'Artikulas',
            'placeholder' => 'Prekės numeris',
            'searchable' => true,
        ],
    ])

The coolest thing is that if second argument is relationship it automatically loads it to this.field.value

Please or to participate in this conversation.