Forms +database+maps

2

Comments

  • edited 11:42AM
    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....
  • edited 11:42AM
    $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

    /*********************** /OVERWRITES ************************************/

    $config['modules']['categories'] = array();
  • edited 11:42AM
    +HOW I CAN MAKE DROPDOWN IN THE FORM WHICH WILL HAVE THE NAME OF CITIES,,,,,ETC
  • edited September 2014
    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).
  • edited 11:42AM
    sorry i could not understand it
  • edited 11:42AM
    function find_location($where)
    {
    $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++;
    }
  • edited 11:42AM
    yes i got it ....now showing successfully......and now i want to add some fields e.g dropdown i know about textfield but how dropdown......
  • edited 11:42AM
    and now when i select the dropdown for categories near search field it says .............
    A Database Error Occurred

    Error Number: 1054

    Unknown column 'locations.category' in 'where clause'
  • edited 11:42AM
    That DB error looks to be a bug that I will need to look into.
  • edited 11:42AM
    okz.....
  • edited 11:42AM
    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
  • edited September 2014
    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; }
  • edited 11:42AM
    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
  • edited 11:42AM
    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;
  • edited 11:42AM
    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....
  • edited 11:42AM
    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
  • edited September 2014
    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.
  • edited 11:42AM
    how i can do things in view ,how to call or show something ...@onegun
  • edited 11:42AM
    u see my example above, inside function view() there is a $vars array, put your varaible name inside , e.g. $vars['category']=array('fruit','meat');

    then inside your views, you can access the variables by doing

    foreach($category as $c) echo $c;
  • edited 11:42AM
    okz let me try
  • edited 11:42AM
    Parse error: syntax error, unexpected T_STRING\fuel\application\controllers\categories.php on line 2

    when i put as u directed
    in view that is categories.php i have
    <?php

    foreach($category as $c) {
    echo $c;
    }


    ?>
  • edited 11:42AM
    solved the above issue and now giving ....

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined variable: category

    Filename: core/Loader.php(332) : eval()'d code

    Line Number: 3
    ....@onegun
  • edited 11:42AM
    did you put i$vars['category'] in your controller?

    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)
  • edited 11:42AM
    still same
    Message: Undefined index: category
  • edited 11:42AM
    post all your codes+filename, so we can take a look
  • edited 11:42AM
    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

    foreach($vars['category'] as $c){
    echo $c;

    }


    ?>
  • edited September 2014
    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);
    }
  • edited 11:42AM
    thanks for your help.....
    Well i did ask some queries from admin. waiting for his kind reply
  • edited 11:42AM
    i want to create same form like i have locations form in admin to add locations for frond end how i can do this please guide me
  • @admin, could I please get a copy of this module to test? Thanks,
Sign In or Register to comment.