1

I created a custom field for Nova. On this field I need to get some extra model data like $model->country to show on the form. How can I pass this data to the Vue component?

I try to use:

return $this->withMeta

But I don't know how to pass the data from the model.

1 Answer 1

4

Add the custom field like a normal field to the resource fields() and chain a custom method with the data from the model:

CountryField::make('Country')->country('Germany'),

Define this custom method in your Nova component (see src folder):

public function country($value)
{
    return $this->withMeta([
        'country' => $value,
    ]);
}

You can access the returned data from this method in FormField.vue like this:

{{ field.country }}
Sign up to request clarification or add additional context in comments.

2 Comments

@Sven Can you please look into this question and give some idea?
But how do you fill 'Germany' with the actual value that is in the model so you can use it in Vue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.