Buy Now
Sign in

Custom Code inside Multiplier container

jhaviro , June 21 2017, 15:28
jhaviro 80
June 21 2017, 15:28 #369677

I have a little question. I need to include inside a container "multiplier" a custom code but in doing so, it destroys the design. The code I need to include is:

$db =& JFactory::getDBO();
$count = $db->loadResult();

$query = "
SELECT DISTINCT `cd_servicio`, `cd_idioma_origen`, `cd_idioma_destino`
FROM `j4tyn_z_tservicios_real` ORDER BY `cd_idioma_origen`;
$data = $db->loadObjectList();
<div class="form-group gcore-form-row" id="form-row-cd_servicio1"><label for="cd_servicio1" class="control-label gcore-label-left">Servicio</label>
<div class="gcore-input gcore-display-table" id="fin-cd_servicio1"><select name="Data[__N__][cd_servicio]" id="cd_servicio__N__" size="0" class="form-control A" title="" style="" data-load-state="" data-tooltip="">
<option value="">-- Seleccionar un Servicio --</option>

$optgroup = '';
foreach ( $data as $d ) {
$selected = '';
if ( $d->id == cd_servicio ) {
$selected = "selected='selected'";
if ( $d->cd_idioma_origen != $optgroup ) {
if ( $optgroup ) {
echo "</optgroup>";
echo "<optgroup label='{$d->cd_idioma_origen}'>";
$optgroup = $d->cd_idioma_origen;
echo "<option value='{$d->cd_servicio}' $selected >{$d->cd_idioma_destino} - Cod: {$d->cd_servicio}</option>";
echo "</optgroup>";

The code works perfectly, is based on this POST
Trying to place the custom code destroys the layout of the form. Can I do it any other way?

Thanks for the help!! Cordially
GreyHead 64
June 22 2017, 09:11 #369717
Hi Javierp,

I'm not sure that this will work at all. The Multiplier adds a copy of some HTML in the browser using JavaScript - the PHP you have here is run on the server before the page is created. You can possibly run the PHP in a Custom Code action before the HTML (Render form) action, add the generated HTML to the $form->data array and then include the result in the multiplier.

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
jhaviro 80
June 22 2017, 15:52 #369753
Good afternoon.

Yes, I'm going to try, although tweaking the design I have managed to leave everything "almost fine". The problem is that, when I place the "custom code", the styles where I apply percentages no longer work ... However, I will try to do as you advise.

Thank you very much.