Forums

filtering a dynamic drop down

Morselli 30 Jan, 2016
HI there,

I'm trying to filtering a dynamic dropdown by "catid" but I'm not able to do it...

This is the code for the dynamic dropdown that populate the array with aticles "name", in this situation i got all the articles name from all the categories, I need to load only froma a single one...
anyone could help me?

I'm not use to php...

thanks!
<?php
$keys = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "f70z2_content")), explode(".", "[n].title"));
$values = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "f70z2_content")), explode(".", "[n].title"));
$options = array_combine($keys, $values);
$field = array (
  'name' => 'Pos_Ape',
  'id' => 'pos_ape',
  'options' => 
  array (
  ),
  'empty' => 'nessuna',
  'values' => 
  array (
  ),
  'label' => 
  array (
    'text' => 'Posizioni Aperte di Interesse #',
    'position' => 'top',
  ),
  'sublabel' => 'Scegli una posizione aperta di interesse',
  'multiple' => '0',
  'size' => '',
  'class' => ' validate[\'required\']',
  'title' => '',
  'style' => '',
  'params' => '',
  ':data-load-state' => '',
  ':data-tooltip' => '',
  'type' => 'dropdown',
  'container_id' => '0',
);
$field["options"] = $options;
echo \GCore\Helpers\Html::formLine($field["name"], $field);
?><fieldset class="chronoform-container" id="Carica-CV">
GreyHead 30 Jan, 2016
Hi Morselli,

I have no idea what this code is or what you need to do.

What do you mean by a Dynamic Drop-down in your form?

Bob
Morselli 30 Jan, 2016
Hi Bob, thanks for your reply,

I populate the dropdown with the title of all the joomla articles (jos_name) but I need to present only the titles from a single category.

I'm using the wizard of ChronoForms 5

thanks
Morselli 30 Jan, 2016
sorry, 'jos_content' - field 'name'
GreyHead 30 Jan, 2016
Hi Morselli,

And where does the Category ID value come from?

Bob
Morselli 30 Jan, 2016
Well Bob,

the "catid" has a fixed value, it must be '19'. I didn't need to change it.
GreyHead 31 Jan, 2016
Answer
Hi Morselli,

Use a DB Read action with settings like this:
+ Table Name - #__content
+ Multi Read - Yes
+ Enable Model ID - Yes
+ Model ID - articles
+ Fields - id.title
+ Conditions - <?php return array ('catid' => 19); ?>

In the DropDown element Dynamic Data tab add:
+ Enabled - Yes
+ Data Path - articles (the Model ID above)
+ Value Key - id
+ Text Key - title

Test . . .

Bob
This topic is locked and no more replies can be posted.