PHP Class View_CRUD, atk4

IMPORTANT NOTE: While you can disable adding and editing, if you do that you must simply use Grid!
Inheritance: extends View
Afficher le fichier Open project: atk4/atk4 Class Usage Examples

Méthodes publiques

Свойство Type Description
$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!');

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
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.

Method Details

addAction() public méthode

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() public méthode

Transparent method for adding buttons to a crud.
public addButton ( string | array $label, string $class = 'Button' ) : Button
$label string | array
$class string
Résultat Button

addFrame() public méthode

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
Résultat Page | boolean Returns object if clicked on popup.

addRef() public méthode

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
Résultat View_CRUD | null Returns crud object, when expanded page is rendered

configureAdd() protected méthode

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
Résultat void | Model If model, then bail out, no greed needed

configureDel() protected méthode

Configures deleting functionality for grid.
protected configureDel ( )

configureEdit() protected méthode

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
Résultat void | Model If model, then bail out, no greed needed

configureGrid() protected méthode

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

formSubmit() protected méthode

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

formSubmitSuccess() public méthode

Returns JavaScript action which should be executed on form successfull submission.
public formSubmitSuccess ( ) : jQuery_Chain
Résultat jQuery_Chain to be executed on successful submit

init() public méthode

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() public méthode

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
Résultat boolean true if editing.

setModel() public méthode

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
Résultat AbstractModel $model

Property Details

$add_button public_oe property

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
Résultat Button

$allow_add public_oe property

$this->add('CRUD', array('allow_add'=>false')); // to disable
public bool $allow_add
Résultat boolean

$allow_del public_oe property

$this->add('CRUD', array('allow_del'=>false')); // to disable
public bool $allow_del
Résultat boolean

$allow_edit public_oe property

$this->add('CRUD', array('allow_edit'=>false')); // to disable
public bool $allow_edit
Résultat boolean

$app public_oe property

public App_Web $app
Résultat App_Web

$entity_name public_oe property

If you set this to 'false' then CRUD will not attempt to change default label ("Add")
public string $entity_name
Résultat string

$form public_oe property

IMPORTANT: check isEditing() method
public Form $form
Résultat Form

$form_class public_oe property

$this->add('CRUD', array('form_class'=>'MyForm'));
public string $form_class
Résultat string

$form_options public_oe property

$this->add('CRUD', array('form_options'=>array('js_widget'=>'ui.atk4_form')));
public array $form_options
Résultat array

$frame_options public_oe property

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
Résultat array

$grid public_oe property

IMPORTANT: check isEditing() method
public Grid $grid
Résultat Grid

$grid_class public_oe property

$this->add('CRUD', array('grid_class'=>'MyGrid'));
public string $grid_class
Résultat string

$grid_options public_oe property

$this->add('CRUD', array('grid_options'=>array('show_header'=>false)));
public array $grid_options
Résultat array

$id public_oe property

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
Résultat mixed

$js_reload public_oe property

Contains reload javascript, used occassionally throughout the object.
public jQuery_Chain $js_reload
Résultat jQuery_Chain

$owner public_oe property

public View $owner
Résultat View

$virtual_page public_oe property

If isEditing() then you can add more stuff on this page, by calling virtual_page->getPage()->add('Hello!');
public VirtualPage $virtual_page
Résultat VirtualPage