Depends on field type

edited August 2016 in Modules
I've set a relationship of "depends on" between a subcategory select and a parent category select (single not multi), but I notice that although the category onchange correctly alters the content of the subcategory select, changing the subcategory select re-fires the ajax and makes subcategory selection impossible. I must be misunderstanding the purpose of the "dependent" type. Once the subcategory options are replaced, I don't want an onchange of the subcategory to retrigger anything.

Comments

  • edited 10:04AM
    What's the code implemented for your fields?
  • edited 10:04AM
    Darn - I never saved the code to Git, and used my own to solve the problem, but it was something like:
    $fields['subcategory'] = array('type' => 'dependent', 'depends_on' => 'category', 'url' => '/fuel/products/ajax_subcategories');
    The method returned the HTML options.
  • edited 10:04AM
    Hmm... I'm having trouble replicating the re-triggering of the ajax call when selecting the sub category.
  • edited 10:04AM
    Further to the above, the select fields had foreign keys set too, and were referenced in a products model.

    I'll try using it again and see if I hit the same issue. The url is arbitrary I suppose, the method for populating the sub category options could be in the subcategory model or the products model (or somewhere else) I take it?
  • edited 10:04AM
    Correct. The URL just needs to return the HTML block of option tags.
Sign In or Register to comment.