coding style - Populating inputs with table values in laravel -


i have profile edit page has multiple fields 1 below. these being populated table values user address if user has address.

it works fine if have 1 table value of these inputs because $address object atleast set.

{{ form::label('firstname', 'first name') }} {{ form::text('firstname', $address->firstname, array('placeholder' => 'please provide first name')) }} 

when have absolute no $address values(absolutely no row in address table user) i'm getting error of:

trying property of non-object

how fix in clean matter? know using isset works clutter inputs fields going:

{{ form::text('firstname', @if(isset($address))$address->firstname @endif, array('placeholder' => 'please provide first name')) }} 

(don't know if correct syntax, idea.)

i can't throw isset around label , input because still need user able set them if there isn't address @ all.

in controller, if user has no address assign new (empty) address , pass in view, way form won't fail, , won't need logic within template.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -