laravel / nova-issues

554 stars 35 forks source link

Default values for fields? #58

Closed Jam0r85 closed 6 years ago

Jam0r85 commented 6 years ago

Not sure if i've missed this from the docs but is there anyway to populate a field in a create form with a default value?

eg.

Date::make('Date')->defaultValue(today())

This would be helpful with relationship fields also, especially with BelongsTo (example of using Spark with it's current_team_id column in the users table.

BelongsTo::make('Team')->defaultValue(Auth::user()->current_team_id)

Would help reduce bits and pieces being added to model observers checking for missing values and populating them etc

AshutoshJha15 commented 3 years ago

Text::make( 'purchase_count') ->default(function (){ return 0; }) ->sortable() ,