⚠ In case you've missed it, we have migrated 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 is an archived forum. ⚠

  •     

profile picture

Field default value from GET method



jopacic
  • profile picture
  • Member

Posted 15 June 2013 - 14:46 PM

Link to my page where grocery CRUD instance is, for example 

index.php/users

.

When I add a new user, URL of the form is 

index.php/users/index/add

, and I use link from external page, that points directly to 

http://domain.com/index.php/users/index/add

 to add new user without displaying the CRUD table first.

 

Now, I would like to set some default value via GET, for example 

index.php/users/index/add?foo=bar

, and set some field's default value to bar if $_GET['foo'] is set.

 

How can I achieve this?


davidoster
  • profile picture
  • Member

Posted 15 June 2013 - 15:04 PM

Hello and welcome to the forums.

You can achieve it either by using getState and before calling the $this->_example_output($output);

make an array($output) of uri data and pass it to the $this->load->view('yourview.php',$output);

 

The other way is to make it straight way by changing the add.php under assets/grocery_crud/themes/your_theme/views

and there use similar code (uri data).


jopacic
  • profile picture
  • Member

Posted 15 June 2013 - 15:35 PM

Hey, thanks for your welcome!

 

I think I will go the 1st way, but I'm not really sure I got you - can you point me to and example?

 

I didn't catch the point on how can I extract my GET key/value pairs using getState method?


goFrendiAsgard
  • profile picture
  • Member

Posted 16 June 2013 - 02:15 AM

This?

if($crud->getState() == 'add'){
    $foo = $this->input->get('foo');
}