-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nova cannot update a table column with a space #6269
Comments
Check the issue with the Laravel Framework team and we have concluded that it's not a common usage and isn't being tested. Since you can't change the database, it could be possible to create an observer to rename /**
* Handle the User "creating" event.
*/
public function creating(Post $post): void
{
$post->setAttribute('Post Name', $post->post_name);
unset($post->post_name);
} |
Alternatively you can set a accessor and mutator to handle this requirements. |
@crynobone Creating a mutator still cannot fix it public function post_name(): Attribute
{
return Attribute::make(
get: fn () => $this->{'Post Name'}
);
} and in the Nova resource Text::make('Post Name', 'post_name')->onlyOnForms(), // doesn't show the value from DB for editing
Text::make('Post Name', 'Post Name')->exceptOnForms(), // shows the value from DB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description:
When you have a table column name with a space, Nova can display the value but you cannot update it.
Detailed steps to reproduce the issue on a fresh Nova installation:
Migrate the table and manually add a record in DB. (maybe using tinker or TablePlus)
Create a Nova Resource:
App\Nova\Post
Add the Field:
Text::make('Post Name', 'Post Name')'
Open the post edit page and try to update it and submit.
The Post Name won't update in the database
Change the table column from
Post Name
to something likepost_name
orpostname
and update the Nova field accordingly.Try to update the same post.
It will update!!!
I have searched for a similar issue on the closed issues table and the discussion tab and it seems no one has ever encountered the same. I am working on a legacy project and I am not allowed to rename the table columns for now. I believe this is a bug.
The text was updated successfully, but these errors were encountered: