diff --git a/README.md b/README.md index 9d31a45..c132c0f 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,240 @@ list set of data from your database : $this->mz_crud->set_config($config); $dataTable = $this->mz_crud->list_('users'); +##Insert + + $config['labels'] = array( 'username'=>'Alias' , 'email'=>'Email' , 'about_me'=> 'About Me' ); + $config['ignor'] = array('id'); + $config['check_duplicate'] = array( 'username' , 'email' ); + $config['redirect'] = base_url().'index/crudList/'; + $config['inp_type'] = array('username'=>'text' , 'about_me'=>'rich_textarea'); + + $this->mz_crud->set_config($config); + $insertTable = $this->mz_crud->add('users'); +##Edit + + $config['labels'] = array( 'username'=>'Alias' , 'email'=>'Email' , 'about_me'=> 'About Me' ); + $config['ignor'] = array('id'); + $config['check_duplicate'] = array( 'username' , 'email' ); + $config['redirect'] = base_url().'index/crudList/'; + $config['inp_type'] = array('username'=>'text' , 'about_me'=>'rich_textarea'); + + $this->mz_crud->set_config($config); + $insertTable = $this->mz_crud->edit( $id , 'users'); + + *see the sample code for more information + + +##Preferences + +The preferences described below . + +Note that not all preferences are availabel for every function. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PreferenceDefault ValuevalueDescriptionAvailability
labelsdatabase column labelarray of 'column'=>'label' pairs Sets the label for each database column in the viewall
ignorNonearray of columnsSets column that should be ignored in the operation all
redirectcurrent_url()stringSets the redirect URL after operation (edit
+ , insert )
add , edit
edit_urlcurrent_url()stringSets the Url to Edit functionlist_
fail_urlcurrent_url()stringSets the redirect URL after operation failsadd , edit
inp_typetype="text"array of 'column'=>'input type' pairs Sets the Html input type for each column.all
optionsempty array2d array of 'column'=>array('option label'=>'option value') Sets the selectable options for input_type of (select , checkbox , radio )all
check_duplicateNonearray of columnschecks the database for duplicate before insert or edit all
md_optionsNonearray( 'add' , 'edit' , 'delete')Sets the moderating options for a list .list_
id_fildidstringsets the id colum in databaseedit
per_page0int sets the per page option for pagination ( 0 == no pagination )list_
searchempty arrayarray of columnssets the searchable colums and adds a search option to the list list_
sortempty arrayarray of columnssets the sortable colums and adds a sort option to the list list_
documentreadyampty arrayarrayjavascript commands to be run on document ready all
langarray('file'=>'crud' , 'folder'=>'crud')arraysets the address for language fileall
+ +##sample code + +lets say we have a table called "users" +users : id , username , email , recive_newsletter , profile + + class index extends CI_Controller { + + function crudList(){ + + $this->load->library('mz_crud'); + + $config['ignor'] = array('id' , 'recive_newsletter' , 'profile' ); + $config['check_duplicate'] = array( 'username' , 'email'); + $config['edit_url'] = base_url().'index/crudEdit/'; + $config['md_options'] = array( 'add' , 'edit' , 'delete'); + $config['labels'] = array( 'username'=>'UserName' , 'email'=>'Email); + $config['per_page'] = 2; + $config['search'] = array( 'username' , 'email'); + $config['sort'] = array( 'username'); + + $this->mz_crud->set_config($config); + echo $this->mz_crud->list_('users'); + + } + + + function crudInsert(){ + + $this->load->library('mz_crud'); + + $config['labels'] = array('username'=>'UserName' , 'email'=>'Email' , 'recive_newsletter'=>'would you like to recive our newsletter' , 'profile'=>'Choose how you share information on your profile ?'); + $config['ignor'] = array('id'); + $config['check_duplicate'] = array( 'username' , 'email' ); + $config['redirect'] = base_url().'index/crudList/'; + $config['inp_type'] = array('newsletter'=>'select' , 'profile'=>'radio'); + $config['options'] = array('newsletter'=>array('Yes , i do'=>'1' , 'No , thanx '=>'0' ) , + 'profile'=>array('i want a public profile '=>'public' , 'i want a private profile'=>'private' )); + $config['documentready'] = array('alert("Please fill in all fields ");'); + + $this->mz_crud->set_config($config); + echo $this->mz_crud->add('users'); + + } + + + + + function crudEdit( $id = 0 ){ + + $this->load->library('mz_crud'); + + $config['labels'] = array('username'=>'UserName' , 'email'=>'Email' , 'recive_newsletter'=>'would you like to recive our newsletter' , 'profile'=>'Choose how you share information on your profile ?'); + $config['ignor'] = array('id'); + $config['check_duplicate'] = array( 'username' , 'email' ); + $config['redirect'] = base_url().'index/crudList/'; + $config['inp_type'] = array('newsletter'=>'select' , 'profile'=>'radio'); + $config['options'] = array('newsletter'=>array('Yes , i do'=>'1' , 'No , thanx '=>'0' ) , + 'profile'=>array('i want a public profile '=>'public' , 'i want a private profile'=>'private' )); + $config['documentready'] = array('alert("Please fill in all fields ");'); + + $this->mz_crud->set_config($config); + echo $this->mz_crud->edit( $id , 'users'); + + } + + + } +