⚠ 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

Custom Add/edit view



rTan
  • profile picture
  • Member

Posted 05 April 2013 - 02:12 AM

I tried to search forum for custom view but not much help.

 

I just want a custom add/edit screen (with tabs and other ui controls).

 

Do I need to create separate theme for each table or is it possible to pass the data from grocery crud to the add/edit view.

 

 

Thanks in advance.

 

 


Zalo
  • profile picture
  • Member

Posted 05 April 2013 - 06:05 AM

You may create your own theme and set it to that GC instance or, you may add some js and css files that change what you need.

When I need tabs for a form, I create a field that it's not on the database and set the tabs code there. You should be able to reorganize everything with jQuery.

Some quick tips:

1- Keep everything within the <form> tag. 

2- Add the tab field at the end of the fields list.

3- Make the jQuery code that sorts your inputs to run JUST AFTER the tab html code instead of inside a $(document).ready(). Otherwise you may need to re-set any datetime fields you have, as well as the rich text editors (ckeditor in my case).

 

If you can't figure how to do it, let me know I think I have an example somewhere but I would recommend you to try to do it yourself first, you may end up with a cleaner way than mine. Otherwise you'll probably just copy-paste :p

 

 

Hope it helped!


davidoster
  • profile picture
  • Member

Posted 05 April 2013 - 17:10 PM

Nice explanation Zalo! Glad to have you around!


Zalo
  • profile picture
  • Member

Posted 05 April 2013 - 18:43 PM

Well... GC saved me hours of work on each project I used it... so, since I am pretty tight with my budget, the LEAST I can do is to spend some of that saved time in the forum :)


Christophe Conduché
  • profile picture
  • Member

Posted 15 April 2013 - 15:38 PM

I'm interested by some code to help me...

 

I would like to solve the problem of the 1:n relation by displaying tabs at the bottom of the add/edit view to show the related items (one tab per item)

 

I have found this post on the forum that display a list on the list.

I would like to adapt position to display tabs on the add/edit view.

 

Any suggestion ?

 

function list_invoices()
{
  $crud = new grocery_CRUD();
  $crud->set_table('invoices');
  $crud->set_subject('invoices');
// add a new column "positions"
  $crud->columns('invoices_id','company_name','positions');
  $crud->callback_column('positions', array($this, 'positions'));
  $output = $crud->render();

  $this->load->view('header',$output);
}
function positions($value, $row)
{
	$html = '<ul>';
	$positions = $this->db->get_where('positions',array('invoices_id'=>$row->invoices_id))->result_array();
	if($positions)
	{
	   foreach ($positions as $items)
	  {
	   $html.='<li>'.$items['title'].'</li>';
	  }
	}
	$html.='</ul>';
	return $html;
}