-
Notifications
You must be signed in to change notification settings - Fork 8
Home
Louis Lam edited this page Oct 20, 2018
·
6 revisions
- Installation
- Database Setup
- Basic Idea
- Quick Notes
- Basic Template
- LouisCRUD Functions for Creating a Structure
- LouisCRUD Functions Used in a Route
- Field
- Field Type
URL Pattern:
http://{your hostname}/index.php/crud/{routeName}
<?php
require "vendor/autoload.php";
use LouisLam\CRUD\SlimLouisCRUD;
use RedBeanPHP\R;
R::setup('sqlite:dbfile.db');
$crud = new SlimLouisCRUD();
$crud->add("book", function () use ($crud) {
$crud->showFields(["id", "title", "date"]);
});
$crud->run();
Function Name | Description |
---|---|
add($routeName, $closure, [tableName, displayName]) | |
config($closure) | |
run() | |
getSlim() |
Function Name | Description |
---|---|
field($fieldName) | |
find($clause, $data) | |
findAll($clause) | |
showFields([...]) | |
hideFields([...]) | |
hideAllFields() | |
notFound() | |
addScript($script) | Add JavaScript to the page. You code MUST be wrapped by <script> tag. |
Event | Description |
---|---|
create(closure) | |
edit(closure) | |
listView(closure) |
Function Name | Description |
---|---|
setDisplayName(name) | Set the display name |
setDefaultValue(val) | |
setValue(val) | |
setFieldType(fieldTypeObject) | |
show() | |
hide() | |
setReadOnly(true) | |
setRequired(true) | |
addValidator(closure) | function ($value, $postData) use ($crud) { } |
$crud->field("active")->setFieldType(new TrueFalse());
OBject Name | Description |
---|---|
new Hidden() | Equivalent to <input type="hidden" />
|
new TextField() | Equivalent to <input type="text" />
|
new Email() | Equivalent to <input type="email" /> . It is for HTML5 only. Be careful if you would like to use on the old browser. |
new Date() | |
new Password() | Equivalent to <input type="password" />
|
new PasswordWithConfirm() | |
new IntegerType() | |
new TextArea() | |
new CKEditor() | |
new TrueFalse() | |
new RadioButton([...]) | |
new Dropdown() | |
new DropdownManyToOne() | |
new CheckboxList() | |
new CheckboxManyToMany() | |
new Image() | |
new GoogleMap() |
You can use $crud->addScript(...) to inject JS code to the page.
$crud->addScript("<script> // Your JS Code Here. </script>");
OBject Name | Description |
---|---|
crud.addValidator(callback) | Add a validator using JavaScript |