PHP Класс View_CRUD, atk4

IMPORTANT NOTE: While you can disable adding and editing, if you do that you must simply use Grid!
Наследование: extends View
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$add_button Button This points to a Button object, which you can change if you want a different label or anything else on it.
$allow_add boolean $this->add('CRUD', array('allow_add'=>false')); // to disable
$allow_del boolean $this->add('CRUD', array('allow_del'=>false')); // to disable
$allow_edit boolean $this->add('CRUD', array('allow_edit'=>false')); // to disable
$app App_Web
$entity_name string If you set this to 'false' then CRUD will not attempt to change default label ("Add")
$form Form IMPORTANT: check isEditing() method
$form_class string $this->add('CRUD', array('form_class'=>'MyForm'));
$form_options array $this->add('CRUD', array('form_options'=>array('js_widget'=>'ui.atk4_form')));
$frame_options array When clicking on EDIT or ADD the frameURL is used. If you want to pass some arguments to it, put your hash here.
$grid Grid IMPORTANT: check isEditing() method
$grid_class string $this->add('CRUD', array('grid_class'=>'MyGrid'));
$grid_options array $this->add('CRUD', array('grid_options'=>array('show_header'=>false)));
$id mixed This is set to ID of the model when are in editing mode. In theory this can also be 0, so use is_null().
$js_reload jQuery_Chain Contains reload javascript, used occassionally throughout the object.
$owner View
$virtual_page VirtualPage If isEditing() then you can add more stuff on this page, by calling virtual_page->getPage()->add('Hello!');

Открытые методы

Метод Описание
addAction ( string $method_name, array $options = [] ) Assuming that your model contains a certain method, this allows you to create a frame which will pop you a new frame with a form representing model method arguments. Once the form is submitted, the action will be evaluated.
addButton ( string | array $label, string $class = 'Button' ) : Button Transparent method for adding buttons to a crud.
addFrame ( string $name, array $options = [] ) : Page | boolean Adds button to the crud, which opens a new frame and returns page to you. Add anything into the page as you see fit. The ID of the record will be inside $crud->id.
addRef ( string $name, array $options = [] ) : View_CRUD | null Assuming that your model has a $relation defined, this method will add a button into a separate column. When clicking, it will expand the grid and will present either another CRUD with related model contents (one to many) or a form preloaded with related model data (many to one).
formSubmitSuccess ( ) : jQuery_Chain Returns JavaScript action which should be executed on form successfull submission.
init ( )
isEditing ( string $mode = null ) : boolean Returns if CRUD is in editing mode or not. It's preferable over checking if($grid->form).
setModel ( string | Model $model, array $fields = null, array $grid_fields = null ) : AbstractModel Assign model to your CRUD and specify list of fields to use from model.

Защищенные методы

Метод Описание
configureAdd ( array $fields = null ) : void | Model Configures necessary components when CRUD is in the adding mode.
configureDel ( ) Configures deleting functionality for grid.
configureEdit ( array $fields = null ) : void | Model Configures necessary components when CRUD is in the editing mode.
configureGrid ( array $fields ) Configures grid's model itself.
formSubmit ( Form $form ) Called after on post-init hook when form is submitted.

Описание методов

addAction() публичный Метод

Assuming that your model contains a certain method, this allows you to create a frame which will pop you a new frame with a form representing model method arguments. Once the form is submitted, the action will be evaluated.
public addAction ( string $method_name, array $options = [] )
$method_name string
$options array

addButton() публичный Метод

Transparent method for adding buttons to a crud.
public addButton ( string | array $label, string $class = 'Button' ) : Button
$label string | array
$class string
Результат Button

addFrame() публичный Метод

The format of $options is the following: array ( 'title'=> 'Click Me' // Header for the column 'label'=> 'Click Me' // Text to put on the button 'icon' => 'click-me' // Icon for button )
public addFrame ( string $name, array $options = [] ) : Page | boolean
$name string Unique name, also button and title default
$options array Options
Результат Page | boolean Returns object if clicked on popup.

addRef() публичный Метод

Adds expander to the crud, which edits references under the specified name. Returns object of nested CRUD when active, or null The format of $options is the following: array ( 'view_class' => 'CRUD', // Which View to use inside expander 'view_options' => .. // Second arg when adding view. 'view_model' => model or callback // Use custom model for sub-View, by default ref($name) will be used 'fields' => array() // Used as second argument for setModel() 'extra_fields' => array() // Third arguments to setModel() used by CRUDs 'label'=> 'Click Me' // Label for a button inside a grid )
public addRef ( string $name, array $options = [] ) : View_CRUD | null
$name string Name of the reference. If you leave blank adds all
$options array Customizations, see above
Результат View_CRUD | null Returns crud object, when expanded page is rendered

configureAdd() защищенный Метод

Configures necessary components when CRUD is in the adding mode.
protected configureAdd ( array $fields = null ) : void | Model
$fields array List of fields for add form
Результат void | Model If model, then bail out, no greed needed

configureDel() защищенный Метод

Configures deleting functionality for grid.
protected configureDel ( )

configureEdit() защищенный Метод

Configures necessary components when CRUD is in the editing mode.
protected configureEdit ( array $fields = null ) : void | Model
$fields array List of fields for add form
Результат void | Model If model, then bail out, no greed needed

configureGrid() защищенный Метод

Configures grid's model itself.
protected configureGrid ( array $fields )
$fields array List of fields for grid

formSubmit() защищенный Метод

Called after on post-init hook when form is submitted.
protected formSubmit ( Form $form )
$form Form Form which was submitted

formSubmitSuccess() публичный Метод

Returns JavaScript action which should be executed on form successfull submission.
public formSubmitSuccess ( ) : jQuery_Chain
Результат jQuery_Chain to be executed on successful submit

init() публичный Метод

CRUD's init() will create either a grid or form, depending on isEditing(). You can then do the necessary changes after Note, that the form or grid will not be populated until you call setModel()
public init ( )

isEditing() публичный Метод

Returns if CRUD is in editing mode or not. It's preferable over checking if($grid->form).
public isEditing ( string $mode = null ) : boolean
$mode string Specify which editing mode you expect
Результат boolean true if editing.

setModel() публичный Метод

public setModel ( string | Model $model, array $fields = null, array $grid_fields = null ) : AbstractModel
$model string | Model Same as parent
$fields array Specify list of fields for form and grid
$grid_fields array Overide list of fields for the grid
Результат AbstractModel $model

Описание свойств

$add_button публичное свойство

This points to a Button object, which you can change if you want a different label or anything else on it.
public Button $add_button
Результат Button

$allow_add публичное свойство

$this->add('CRUD', array('allow_add'=>false')); // to disable
public bool $allow_add
Результат boolean

$allow_del публичное свойство

$this->add('CRUD', array('allow_del'=>false')); // to disable
public bool $allow_del
Результат boolean

$allow_edit публичное свойство

$this->add('CRUD', array('allow_edit'=>false')); // to disable
public bool $allow_edit
Результат boolean

$app публичное свойство

public App_Web $app
Результат App_Web

$entity_name публичное свойство

If you set this to 'false' then CRUD will not attempt to change default label ("Add")
public string $entity_name
Результат string

$form публичное свойство

IMPORTANT: check isEditing() method
public Form $form
Результат Form

$form_class публичное свойство

$this->add('CRUD', array('form_class'=>'MyForm'));
public string $form_class
Результат string

$form_options публичное свойство

$this->add('CRUD', array('form_options'=>array('js_widget'=>'ui.atk4_form')));
public array $form_options
Результат array

$frame_options публичное свойство

When clicking on EDIT or ADD the frameURL is used. If you want to pass some arguments to it, put your hash here.
public array $frame_options
Результат array

$grid публичное свойство

IMPORTANT: check isEditing() method
public Grid $grid
Результат Grid

$grid_class публичное свойство

$this->add('CRUD', array('grid_class'=>'MyGrid'));
public string $grid_class
Результат string

$grid_options публичное свойство

$this->add('CRUD', array('grid_options'=>array('show_header'=>false)));
public array $grid_options
Результат array

$id публичное свойство

This is set to ID of the model when are in editing mode. In theory this can also be 0, so use is_null().
public mixed $id
Результат mixed

$js_reload публичное свойство

Contains reload javascript, used occassionally throughout the object.
public jQuery_Chain $js_reload
Результат jQuery_Chain

$owner публичное свойство

public View $owner
Результат View

$virtual_page публичное свойство

If isEditing() then you can add more stuff on this page, by calling virtual_page->getPage()->add('Hello!');
public VirtualPage $virtual_page
Результат VirtualPage