Closed LorenzoSapora closed 5 years ago
Hey! The button becomes disabled
when the field is in the middle of a request (ie fetching notes or submitting a note). I think either fetching notes or submitting a note failed.
Did you run the migrations and add the HasNotes trait to the model?
Aha, could it possibly be actions that's causing this issue? I have actions on this resource, and that's refreshing every 10s
I don't think so. Can you check for any errors in the console?
Yep, all migrated. I've added it to a very basic resource, without actions, and it's exhibiting the same issue. The only error I have in my console is a 404. but it's inside my nova js, so I'll have to uncompile that to see what's failing.
My current code block (truncated)
[..]
use OptimistDigital\NovaNotesField\Traits\HasNotes;
use OptimistDigital\NovaNotesField\NotesField;
class GameFeatured extends Resource
{
use HasNotes;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),
[..]
NotesField::make('Notes')
->placeholder('Add note'), // Optional
];
}
Hey. You added HasNotes to the resource, it should be on the Model.
Idiota! Apologies. I'll write up a pull request for the docs, to make it a little more clearer. Thanks for your time.
Cheers, glad it worked!
Aha, reopening because it's still unclickable.
Resource:
<?php
namespace App\Nova;
use Laravel\Nova\Fields\{ID, BelongsTo, DateTime};
use Illuminate\Http\Request;
use Laravel\Nova\Http\Requests\NovaRequest;
use OptimistDigital\NovaNotesField\NotesField;
class GameFeatured extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = 'App\Models\GameFeatured';
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'id';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'id',
];
public static function label() {
return 'Featured';
}
public static function uriKey() {
return 'featured';
}
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()
->sortable(),
NotesField::make('Notes')
->placeholder('Add note'), // Optional
];
}
[...]
Model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use OptimistDigital\NovaNotesField\Traits\HasNotes;
class GameFeatured extends Model
{
use HasNotes;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'game_featured';
protected $casts = [
'start' => 'date',
'end' => 'date',
];
[...]
Now that I think about it, I believe I made it so it's also disabled when the field is empty, did you try entering anything?
I did, sorry the screenshot doesn't reflect this.
What Laravel Nova version are you using?
2.5.0
Definitely relating to the 404 error I'm getting. Give me a minute and I'll get the block of JS it's 404ing on
That's really weird. The only thing I can imagine would cause this is if /nova-vendor/nova-notes/notes
request failed for some reason.
Maybe your routes are cached and the nova-vendor routes are not loaded? 🤷♂
Hmm. It seems you're right, although I'm not entirely sure why. But for future explorers, running
php artisan cache:clear;php artisan config:clear;php artisan route:clear;php artisan view:clear;php artisan optimize;php artisan clear-compiled;composer dump-autoload;php artisan config:cache;php artisan route:cache;php artisan view:cache;
Cleared everything out for me. Sorry for wasting so much of your time.
Awesome, I think the routes were cached and it wasn't loading the new ones. Running php artisan route:clear
would've probably been enough.
Hey Tarvo,
Following your readme instructions, and when viewing, the submit button is unclickable.
Assumed maybe a character limit, that's why I copy pasted 'test' so many times.
Attempted to remove the disabled=disabled from the button itself, but still doesn't allow me to click
Nova: 2.5.0 Laravel: 5.8~ This package: 1.0.2