<?php $firstName=isset($contact) ? $contact->first_name : '' ?>
<input type="text" value="{{ old('first_name',$firstName )}}" >
It will solve throw errors.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This, to me atleast, feels like a clean way to have edit & create views share fields
Shared Input
<input type="text" name="first_name" value="{{ old('first_name', $contact->first_name) }}">
Create & Edit Method - Because $contact isn't defined in create it throws an exception.
Any opinions / thoughts on adding an empty model, making the default value of old() = empty.
public function create()
{
return view('contact.create')->withContact(new Contact);
}
public function edit($id)
{
$contact = Contact::find($id);
return view('contact.edit', compact('contact'));
}
Please or to participate in this conversation.