Forums

multiplier witha fix value

cornelio 04 Nov, 2015
hi,
using multiplier container I built a form with a dropdown and an input field in which I have called id by = gcb , that remains constant.

when I create a new record with multiplier I wish you duplicate only the value of the drop and maintained fixed the id.

the script of this form:
<?php
$keys = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "path_codice")), explode(".", "[n].ad_codice"));
$values = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "path_codice")), explode(".", "[n].ad_descrizione_ana"));
$options = array_combine($keys, $values);
$field = array (
  'name' => 'ademp_soggetti[__N__][id_codice_ademp_soggetto]',
  'id' => 'id_codice_ademp_soggetto-__N__',
  'options' => 
  array (
    0 => 'No',
    1 => 'Yes',
  ),
  'empty' => '',
  'values' => 
  array (
  ),
  'label' => 
  array (
    'text' => 'CodiceAdemp # __N__',
    'position' => 'top',
  ),
  'sublabel' => '',
  'multiple' => '0',
  'size' => '',
  'class' => '',
  'title' => '',
  'style' => '',
  'params' => '',
  ':data-load-state' => '',
  ':data-tooltip' => '',
  'type' => 'dropdown',
  'container_id' => '12',
);
$field["options"] = $options;
echo \GCore\Helpers\Html::input($field["name"], $field);
?>
id:<input type="text" name="id_cliente[]" id="id_cliente[]" value="<?php echo $form->data['idclientex'];?>" class="SS form-controll"/>



on submit, however, I can not enter value of the id


debugger:

Array
(
    [cont] => lists
    [ccname] => elenco_soggetti
    [act] => view
    [gcb] => 938
    [chronoform] => copia3-sia-config-ademp-clienti-fields-multiplier2
    [event] => submit
    [ademp_soggetti] => Array
        (
            [0] => Array
                (
                    [id_codice_ademp_soggetto] => AD001
                )

            [2] => Array
                (
                    [id_codice_ademp_soggetto] => AD014
                )

            [3] => Array
                (
                    [id_codice_ademp_soggetto] => AD001
                )

            [id_cliente] => 338 this is n. of record !
        )

    [id_cliente] => Array
        (
            [0] => 938
            [1] => 938
            [2] => 938
        )

    [button5] => Registra


Regards

Cornelio
GreyHead 04 Nov, 2015
Hi Cornelio,

Sorry I don't understand what your question is, or what the code is you posted in the first box.

Bob
cornelio 04 Nov, 2015
Hi Bob,

Thank you for answering
attached form:

[attachment=0]multip.JPG[/attachment]

and that the debugger:

Array
(
    [cont] => lists
    [ccname] => elenco_soggetti
    [act] => view
    [gcb] => 938
    [chronoform] => copia3-sia-config-ademp-clienti-fields-multiplier2
    [event] => submit
    [ademp_soggetti] => Array
        (
            [0] => Array
                (
                    [id_codice_ademp_soggetto] => AD001
                )

            [2] => Array
                (
                    [id_codice_ademp_soggetto] => AD014
                )

            [id_cliente] => 340
        )

    [id_cliente] => Array
        (
            [0] => 938
            [1] => 938
        )

    [button5] => Registra

Array
(
    [24] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `bqu1s_f_tadempimenti_soggetto` (`id_codice_ademp_soggetto`) values ('AD001');
                            [1] => INSERT INTO `bqu1s_f_tadempimenti_soggetto` (`id_codice_ademp_soggetto`) values ('AD014');
                        )

                )

        )

)


I think that the problem is in the input field that should be so:
<input type="text" name="name_model[id]" id=id/>

but don't work.

Regards
GreyHead 04 Nov, 2015
Hi Cornelio,

I'm sorry I still don't understand what you are trying to do here.

If the ID needs to be the same for each copy of the multiplier then it doesn't need to be in the multiplier - you can add it later.

Bob
cornelio 05 Nov, 2015
Hi Bob,

If the ID needs to be the same for each copy of the multiplier then it does not need to be in the multiplier - you can add it later.


Yes, ID is the same for each copy. the query generated is correctly but instead of INSERT writes UPDATE.

Regards

Cornelio
cornelio 05 Nov, 2015
Answer
Hi Bob,

I solved it by setting the setup Force save on action on DBSave

Regards

Cornelio
GreyHead 05 Nov, 2015
Hi Cornelio,

Force will work OK here,

ChronoForms will use UPDATE if there data include a record id that already exists in the table - usually this will be the value id or cf_id. If you want to create an INSERT then you need to remove any values like this from the form data:
<?php
unset($form->data['id']);
?>

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