Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

DataEdit

zofe edited this page Sep 18, 2014 · 18 revisions

DataEdit extends DataForm, it's a full CRUD application for given Entity.
It has status (create, modify, show) and actions (insert, update, delete) It detect status by simple query string semantic:

  /dataedit/uri                     empty form    to CREATE new records
  /dataedit/uri?show={record_id}    filled output to READ record (without form)
  /dataedit/uri?modify={record_id}  filled form   to UPDATE a record
  /dataedit/uri?delete={record_id}  perform   record DELETE
  ...
   //simple crud for Article entity
   $edit = DataEdit::source(new Article);
   $edit->link("article/list","Articles", "TR")->back();
   $edit->add('title','Title', 'text')->rule('required');
   $edit->add('body','Body','textarea')->rule('required');
   $edit->add('download','Attachment', 'file')->rule('mime:pdf')->move('uploads/pdf/');
   $edit->add('photo','Photo', 'image')->rule('mimes:jpeg')->move('uploads/images/')->fit(320,240);
   $edit->add('author.fullname','Author','autocomplete')->search(array('firstname','lastname'));
   
   return $edit->view('crud', compact('edit'));
   #crud.blade.php
  {{ $edit }}

As you see you can append fields and links, while the "buttons" (save, undo, delete, etc..) and messages (like delete confirmation) are fully managed by dataedit.

In demos we use "link" method on dataedit to build a back_link to a datagrid. parameters are: ->link($uri, $label, $position) $uri and $label are quite simple to understand, the last parameter $position is the position where the button will appear: ["TR","BL","BR"] (top right, bottom left, bottom right). TL is not valid because this position is reserved to show widget label.

You can add a ->back() or more specific ->back('do_delete|update') to a link if you want to auto-pull back after all actions (or after some of these).

note: we use $edit->view method instead View::make for a reason: DataEdit must manage redirects. With other widgets you should use View facade as default.

Clone this wiki locally