⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠

Enter Default Values with Add & Update in Grocery CRUD

default values crud

  • Please log in to reply
No replies to this topic

#1 niketnaik



  • Members
  • Pip
  • 1 posts

Posted 06 December 2018 - 05:28 AM

I am using Grocery CRUD for my project though i am currently new to Grocery CRUD and i am facing very basic problem with it. what i want is to add some default values when we add or update the data with CRUD. to understand better here is my table structure
ID(AI,PK) | Username | Password |CreatedAt|UpdatedAt|CreatedBy|UpdatedBy|

Above is the table structure where i am just entering the username and password, and CreatedAt|UpdatedAt|CreatedBy|UpdatedBy| will be added autometically.

here is my code to add the username and password

public function crudUsers()
$crud = new grocery_CRUD();

$crud->set_subject("Website Users");

// Show in
$crud->add_fields(["username", "password"]);
$crud->edit_fields(["username", "password"]);
$crud->columns(["username", "password","CreatedAt","UpdatedAt","CreatedBy","UpdatedBy"]);

$data = (array) $crud->render();

$this->layout->set_wrapper( 'grocery', $data,'page', false);

$template_data['grocery_css'] = $data['css_files'];
$template_data['grocery_js'] = $data['js_files'];
$template_data["title"] = "Website Pages";
$template_data["crumb"] = ["table" => ""];
$this->layout->render('admin', $template_data); 

I have tried using https://www.groceryc...ck_after_update this works but i don't find it is good approach to insert and update values again using query. Also the callbacks needs to be created for each and every functions i will use in future.


I like this and tried the code https://www.amitsgar...es-for-add-form

This code gives the error at "$data->field_values = $this->get_add_values(null); " because this function is not there which is obvious.

I have tried other multiple options but can not able to find any good universal function which help me.

Any suggestions please? 


Also tagged with one or more of these keywords: default values, crud

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users