yes i do have those categories setup is working but the category section in your module for locations is not working, when i add a category by clicking add button it pop up a form for categories and add successfully but not showing in drop down....
$config['module_overwrites']['categories']['hidden'] = FALSE; // change to FALSE if you want to use the generic categories module $config['module_overwrites']['tags']['hidden'] = FALSE; // change to FALSE if you want to use the generic tags module
For the dropdowns to show up, they need the context value of "locations" (note the where condition in the locations_model.php file for the $foriegn_key parameter).
please guide me how to create dropdown in location creation form e.g like i want to show all cities of a specific country in dropdown and i want to populate dropdown from database...plus how can i change the orders of the fields in the form
For modifying the locations form, you'll need to modify the locations_model::form_fields method. In your case, you'll want to change the "cities" field to a dropdown. To do that, I'd do something like this:
function form_fields($values = array(), $related = array())
{
$fields = parent::form_fields($values, $related);
$fields['latitude']['comment'] = 'This value will automatically be generated by Google\'s geolocation service if the address is legit';
$fields['longitude']['comment'] = 'This value will automatically be generated by Google\'s geolocation service if the address is legit';
$my_array_of_cities = array('city1' => 'city1', 'city2' => 'city3');
$fields['city'] = array('type' => 'select', 'options' => $my_array_of_cities);
// if you want to pull the options from a model
//$fields['city'] = array('type' => 'select', 'model' => 'my_city_model');
return $fields;
}
Yes i got it ......and done it Thanks a lot......One thing more is it true if i want to change the fields order in form i have to change the order in table in mysql if not then how i can do this and second thing i am using categories in location form as a province and its working nicely but i want to change the Category label to Province in filter records area..... and plus i am successful in showing map ....but i want to highlight
First, the fix for the category dropdown in the list view is to replace line 10 in the locations_fuel_module.php file with the following (note the key is changed from "category" to "fuel_categories:id"): 'filters' => array('fuel_categories:id' => array('type' => 'select', 'label' => 'Category', 'model' => 'fuel_categories', 'model_params' => array('id', 'name', array('context' => 'locations')), 'first_option' => 'Select a category...'))
To change the label, you add the "label" => "Province" to the locations_model::form_fields method like so:
...
$field['category']['label'] = 'province';
...
return $fields;
Thanks a lot yes its done now.... now i want to use same this type of form to be use on front end so user can add locations from front end that form will have captcha as well to avoid spam....how i can do that please guide me Bundle of Thanks for your guidelines....
i have read your this tutorial but there is no clear where to create controller and where to create view and how to call form in view ...my bad luck not getting it
you can create controller at fuel/application/controllers folder, using normal class will do
e.g.
Class Categories extends CI_Controller{ function Categories(){ parent::__construct(); $this->load->database();//for you talk to database } function view(){ $vars=array(); $this->fuel->pages->render('categories',$vars); } }
you can create views at fuel/application/views as render above mentioned file name to be "categories", you create another categories.php as view file
that is it. you may need to set routing for it, though.
okz This is controller in application/controllers/categories ?php Class Categories extends CI_Controller{ function Categories(){ parent::__construct(); $this->load->database();//for you talk to database } function view(){ $vars['category']=array('fruit','meat'); //$this->fuel->pages->render('categories',$vars); $this->fuel->pages->render('categories',$vars); } } and this is view....in application/views/categories <?php
i think the problem may because you did not set the route, you can set routing at routes.php meanwhile, to solve this problem in this particular case without the need of setting route.
change function view(){} in controller to
function index(){ $vars['category']=array('fruit','meat'); //$this->fuel->pages->render('categories',$vars); $this->fuel->pages->render('categories',$vars); }
Comments
$config['module_overwrites']['tags']['hidden'] = FALSE; // change to FALSE if you want to use the generic tags module
/*********************** /OVERWRITES ************************************/
$config['modules']['categories'] = array();
{
$this->db->select('locations.*, '.$this->_tables['fuel_categories'].'.slug as category, '.$this->_tables['fuel_categories'].'.slug as category_slug');
$data = $this->locations_model->find_all_array($where);
$i = 1;
foreach($data as $k => $v)
{
$data[$k]['markerText'] = "{$i}";
$i++;
}
A Database Error Occurred
Error Number: 1054
Unknown column 'locations.category' in 'where clause'
function form_fields($values = array(), $related = array()) { $fields = parent::form_fields($values, $related); $fields['latitude']['comment'] = 'This value will automatically be generated by Google\'s geolocation service if the address is legit'; $fields['longitude']['comment'] = 'This value will automatically be generated by Google\'s geolocation service if the address is legit'; $my_array_of_cities = array('city1' => 'city1', 'city2' => 'city3'); $fields['city'] = array('type' => 'select', 'options' => $my_array_of_cities); // if you want to pull the options from a model //$fields['city'] = array('type' => 'select', 'model' => 'my_city_model'); return $fields; }
and second thing i am using categories in location form as a province and its working nicely but i want to change the Category label to Province in filter records area.....
and plus i am successful in showing map ....but i want to highlight
'filters' => array('fuel_categories:id' => array('type' => 'select', 'label' => 'Category', 'model' => 'fuel_categories', 'model_params' => array('id', 'name', array('context' => 'locations')), 'first_option' => 'Select a category...'))
To change the label, you add the "label" => "Province" to the locations_model::form_fields method like so:
... $field['category']['label'] = 'province'; ... return $fields;
now i want to use same this type of form to be use on front end so user can add locations from front end that form will have captcha as well to avoid spam....how i can do that please guide me
Bundle of Thanks for your guidelines....
e.g.
Class Categories extends CI_Controller{
function Categories(){
parent::__construct();
$this->load->database();//for you talk to database
}
function view(){
$vars=array();
$this->fuel->pages->render('categories',$vars);
}
}
you can create views at fuel/application/views
as render above mentioned file name to be "categories", you create another categories.php as view file
that is it. you may need to set routing for it, though.
then inside your views, you can access the variables by doing
foreach($category as $c) echo $c;
when i put as u directed
in view that is categories.php i have
<?php
foreach($category as $c) {
echo $c;
}
?>
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: category
Filename: core/Loader.php(332) : eval()'d code
Line Number: 3
....@onegun
also you need to do $this->fuel->pages->render('categories',$vars); in your view function. If still cant get the result try in your view
foreach($vars['category'] as $c)
Message: Undefined index: category
This is controller in application/controllers/categories
?php
Class Categories extends CI_Controller{
function Categories(){
parent::__construct();
$this->load->database();//for you talk to database
}
function view(){
$vars['category']=array('fruit','meat');
//$this->fuel->pages->render('categories',$vars);
$this->fuel->pages->render('categories',$vars);
}
}
and this is view....in application/views/categories
<?php
foreach($vars['category'] as $c){
echo $c;
}
?>
meanwhile, to solve this problem in this particular case without the need of setting route.
change function view(){} in controller to
function index(){
$vars['category']=array('fruit','meat');
//$this->fuel->pages->render('categories',$vars);
$this->fuel->pages->render('categories',$vars);
}
Well i did ask some queries from admin. waiting for his kind reply