How to insert custom CSS in forms?
- Single Page
Posted 07 December 2011 - 12:55 PM
Posted 07 December 2011 - 19:09 PM
I want to insert some Custom CSS element [e.g., to have two-col layout] in the default Add/Edit generated forms, would appreciate if anyone or the Admin can give me some pointers to achieve this.
[/quote]
A simple way to do this is to use the getState method. You have to use it always after the render function. You can see an example at: http://www.grocerycr...n_name/getState . In your case you will do something like this:
.....
$crud->set_subject(....);
.....
$crud->...etc
$output = $crud->render();
$state = $crud->getState();
if($state == 'add')
{
$output->css_files[] = base_url().'assets/css/yourcustom.css';
$output->css_files[] = base_url().'assets/css/yourcustom2.css';
}
elseif($state == 'edit')
{
$output->css_files[] = base_url().'assets/css/yourcustom.css';
$output->css_files[] = base_url().'assets/css/yourcustom2.css';
}
$this->_example_output($output);
....
The same thing you can do it with javascript also. I have a solution to have it in the views. But because in every version something could change in javascript/css/views it is better to not change the core.
Posted 07 December 2011 - 19:34 PM