trying display empty string model html control in laravel 5 blade template.
{!! form::label('labeloccupation',$mastermodel->occupation,['style'=>'background-color:#bcbcbc']) !!}
{!! form::text('textoccupation',$mastermodel->occupation,['style'=>'background-color:#bcbcbc']) !!}
both text , label control can display value of occupation field correctly. when value empty string, label control display wording "occupation", while text control still able show empty.
does means have check empty string exists in model every time when loading value label? other easier methods handle such case?
you can way on controller before passing label on form:
if(empty($mastermodel->occupation) { $occupation_label = 'occupation'; } else { $occupation_label = $mastermodel->occupation; }
then pass use in blade:
{!! form::label('labeloccupation',$occupation_label,['style'=>'background-color:#bcbcbc']) !!}
i think it's easiest way achieve this.
Comments
Post a Comment