PHP 클래스 View_CRUD, atk4

IMPORTANT NOTE: While you can disable adding and editing, if you do that you must simply use Grid!
상속: extends View
파일 보기 프로젝트 열기: atk4/atk4 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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