davidpiesse / nova-map

Laravel Nova Map Field
114 stars 29 forks source link

Nova methods are ignored on map field (like hideWhenCreating) #5

Closed bernhardh closed 5 years ago

bernhardh commented 5 years ago

You wrote in your readme, that "The field is disabled in Index and Form views by default" but in my case its shown up in edit mode (aka Form view).

image

Even if I add the hideWhenCreating/hideWhenUpdating methods.

            Map::make('Karte', 'geocoordinates')
                ->spatialType('Point')
                ->height("300px")
                ->hideWhenCreating()
                ->hideWhenUpdating(),

But on detail view, everything is working:

image

davidpiesse commented 5 years ago

Hi @bernhardh BY default it is disabled

public $showOnUpdate = false;
public $showOnIndex = false;

However this may not be right for both create and edit. I will have to check that. Is it just for the create form or for both?

davidpiesse commented 5 years ago

Thinking about this however your code

->hideWhenCreating()
->hideWhenUpdating(),

should force this but it doesn't.... hmmm

bernhardh commented 5 years ago

Ok, I tried it out on another model and there it works, but you will have to add showOnCreation=true as well as default behavior (as long as editing doesn't work).

    /**
     * Indicates if the element should be shown on the creation view.
     *
     * @var bool
     */
    public $showOnCreation = true;

    /**
     * Indicates if the element should be shown on the update view.
     *
     * @var bool
     */
    public $showOnUpdate = true;

I'm still having the described problem with another model, but thats probably connected with another package I am using (michielkempen/nova-polymorphic-field).

bernhardh commented 5 years ago

Just for the records:

https://github.com/michielkempen/nova-polymorphic-field/issues/5