2017 © Pedro PelĂĄez
 

yii2-extension yii2-crud

Yii2 extension that provides default CRUD for AR models.

image

netis/yii2-crud

Yii2 extension that provides default CRUD for AR models.

  • Friday, December 16, 2016
  • by nineinchnick
  • Repository
  • 2 Watchers
  • 3 Stars
  • 640 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 14 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

yii2-crud

Provides:, (*1)

  • base ActiveRecord class with behaviors
  • base ActiveQuery class for advanced search
  • model generator
  • ActiveController and a set of Action classes providing a RESTful service with a default HTML format
  • default views mechanism

ActiveRecord

Filtering

Filters are separated from validator rules. This allows to perform filtering and validation separately. This is sometimes required when filters modify values in such way they can't be applied twice., (*2)

This is implemented in the netis\crud\db\FilterAttributeValuesTrait trait. The base AR class also introduces two new events, beforeFilter and afterFilter., (*3)

Relations

Since the CRUD renders all model relations, they need to be enumerated in the model. This is done in the new relations() method., (*4)

Saving relations is done by using the netis\crud\db\LinkableBehavior behavior., (*5)

Relations are also used for authorization. The base AR class has the netis\rbac\AuthorizerBehavior attached., (*6)

Labels

Models can be cast to string, because the base AR class implements the __toString() method. By attaching the netis\crud\db\LabelsBehavior behavior, you can select attributes used to generate a string representation of a specific model. The behavior also allows to define general label for a model and its relations., (*7)

Attribute formats

Formatter formats can be assigned to model attributes in the attributeFormats() method. Defaults are detected based on the database column types., (*8)

ActiveController

Response formats

The default response format is HTML. Other supported formats include JSON and XML., (*9)

When an action returns a large collection, streaming is used to output data. This is slower, but allows to send an extremely large response and renders and output data at the same time. Thanks to this, paging is not necessary to export whole contents of the database tables., (*10)

New formats can be easily added, but this requires providing both a renderer stream and a response formatter classes., (*11)

Default views

Defaults views are provided for the HTML response format. They support overriding in the same fashion as in themes., (*12)

Form builder

For the update action's form, the fields are automatically generated based on model's attributes, relations and their formats., (*13)

Relations

The view and update actions display all model relations either as single values (_hasOne_) or grids (_hasMany_). In the update action, for both relation types, new or existing records can be associated with the model being updated., (*14)

A context menu is available., (*15)

Composite keys

Both primary and foreign composite keys (consisting of two or more columns) are fully supported., (*16)

The Versions