nested select field

Discussion in 'General Chat' started by coquendo, Apr 2, 2018.

  1. coquendo

    coquendo New Member

    Hello colleagues,
    I am still learning to program in Subrion CMS and I need to do something simple but in Subrion it is a little complicated for me.
    I want to make a combobox that changes according to the value of another combobox, as it is used in countries and cities.
    I've the following code:
    Code (Javascript):
    //chance cities
    $("#state").change(function() {
         $("#state option:selected").each(function() {
          id_state = $(this).val();
               url: '../../admin/items.php/_chanceCity()',
               type: 'POST',
               data: {id_state: id_state},
               .done(function() {
               alert("success -> "+id_state);
               .fail(function() {
               alert("error -> "+id_state);
    class iaBackendController extends iaAbstractControllerModuleBackend
    //Update cities field
    public function _chanceCity()
          $state = $_POST['id_state'];
          $cities = $this->_iaDb->onefield(iaDb::ID_COLUMN_SELECTION, 'state='.$state, 0, 0, 'city');
          $iaView->assign('cities', $cities);
    The problem is that I don't know how to access the php function, within the iaBackendController class.

    If anyone can help me I appreciate it.
  2. Dayir_A.

    Dayir_A. Staff Member

    Hello @coquendo,

    For Ajax calls please use
    Code (Text):
    the syntax is the same as
    Code (Text):
    the only difference is it adds CSRF token which is required.

    and the js would look something like:
    Code (Text): + '/actions/read.json', {action: 'custom-action'}, function (response) { });
    PHP handler of this AJAX call is /admin/actions.php and the code would look like this:
    Code (Text):

    switch ($_POST['action']) {
    case 'custom-action':// your code goes here...break;
    Hope this helps.
  3. coquendo

    coquendo New Member

    Excellent information, that helped me understand more the operation of Subrion.
    I already managed to do what I needed.

    Thank you very much @Dayir_A.
  4. coquendo

    coquendo New Member

    But how can I call a php file that is in another route? I would like to create a new php file.
  5. Dayir_A.

    Dayir_A. Staff Member

    You should add a page (if admin then to {prefix}admin_pages, if front then to {prefix}pages table accordingly) and in that inserted row set the filename column to file name you've added without the extension (index.php should be just index)
    alias column is the part of the url. f.e. if alias = 'custom-page', then path to that page would look like:
    to access it via AJAX, please appedn .json or /read.json like in my previous comment.
    coquendo likes this.
  6. tom121

    tom121 New Member

    I wish I saw this information sooner

Share This Page