Thursday, March 16, 2017

Best practice to use same blade to add and edit content

I'm creating a simple blog and I'm trying to use the same blade to edit and add article.

I've manage to make it work but I think the way I'm doing it is pretty strange. I have to use in the blade if(!empty($article)) or .

Is there a better way of doing it ? Is it bad practice to try to mix them up ?

Here is my add/edit/blade for better understanding

<form method="post" action="/blog/">
    
    @if(!empty($article))
    <input type="hidden" name="_method" value="PUT">
    @endif
    <input type="text" name="title" class="form-control" value="" />
    <textarea name="content" class="form-control"></textarea>
    <button type="submit">Envoyer</button>
</form>



via Baldráni

Advertisement