autofill form

coullet

Member
Hi,
i'm searching a way to do that:
a form with a database join element with " add option in front end"
when add is clicked, i need to fill some element of the new record, with values of the first form.

I try with autofill plugin, but it doesn't work, i think because the id is not set as this moment.

Thanks
 
Hmmm.

I think you could do this by overriding ...

..\plugins\fabrik_element\databasejoin\layouts\fabrik-element-databasejoin-form-front-end-select.php

I'm about to commit a small change which will provide that layout with $d->rowData.

That way you could append the query string args to set the defaults to relevant elements, like

Code:
&thattable___foo=<?php echo $d->rowData['thistable___foo']; ?>

-- hugh
 
Sorry, don't see where i could to append query string...in the databasjoin layout php file you talk?
Thanks!
 
Yup. This is where the button is rendered

Code:
if ($d->frontEndAdd && $d->editable) :
    JText::script('PLG_ELEMENT_DBJOIN_ADD');
    ?>
    <a href="<?php echo $d->addURL; ?>" title="<?php echo FText::_('COM_FABRIK_ADD');?>" class="toggle-addoption btn">
        <?php echo FabrikHelperHTML::image('plus.png', 'form', @$d->tmpl, array('alt' => FText::_('COM_FABRIK_SELECT'))); ?>
    </a>
<?php
endif;

So you should be able to append whatever you need to that $d->addURL, picked from the $d->rowData array. Like ...

Code:
if ($d->frontEndAdd && $d->editable) :
    JText::script('PLG_ELEMENT_DBJOIN_ADD');
    ?>
    <a href="<?php echo $d->addURL . '&thattable_foo=' . $d->rowData['thistable___foo']; ?>" title="<?php echo FText::_('COM_FABRIK_ADD');?>" class="toggle-addoption btn">
        <?php echo FabrikHelperHTML::image('plus.png', 'form', @$d->tmpl, array('alt' => FText::_('COM_FABRIK_SELECT'))); ?>
    </a>
<?php
endif;

See the wiki for how to override this template for just a single element, by copying it to a named folder in your site template layouts.

-- hugh
 
Mmmm, i'm loosing my mind...
I test yesterday and it work.
Today i will complete with other field, and nothing...

Code:
if ($d->frontEndAdd && $d->editable) :
    JText::script('PLG_ELEMENT_DBJOIN_ADD');
    ?>
    <a href="<?php echo $d->addURL . '&eqds_bordereaux___categorie_raw=3' .'&eqds_bordereaux___seance_id_raw=' . $d->rowData['eqds_planning_diffusion___id'] . '&eqds_bordereaux___film_id_raw=' . $d->rowData['eqds_planning_diffusion___film_id_raw']; ?>" title="<?php echo FText::_('COM_FABRIK_ADD');?>" class="toggle-addoption btn">
        <?php echo FabrikHelperHTML::image('plus.png', 'form', @$d->tmpl, array('alt' => FText::_('COM_FABRIK_SELECT'))); ?>
    </a>
<?php
endif;

this one is ok: '&eqds_bordereaux___categorie_raw=3'
but not the other which use rowData...
 
nothing silly like having changed your Template?
Try just adding an "echo "hello"; to the override to ensure that its actually being loaded?
 
Try dumping the rowData, right after $d is assigned ...

Code:
$d = $displayData;
var_dump($d->rowData);exit;

... and see what is displayed in the browser.

-- hugh
 
for dbjoin element, raw value is an array :
["eqds_planning_diffusion___film_id_raw"]=> array(1) { [0]=> string(1) "1" }
I need php learning: don't found the syntax to access to the value...

for date element, it's a string
["eqds_planning_diffusion___date_projection_raw"]=> string(19) "2016-02-20 12:00:00"
assign to a date element do nothing
 
That's what i first try, so i do not need learning, but new glasses: typo between rawData and rowData...;)

For date element, i don't already have it, so if you see something...

Code:
    <a href="<?php echo $d->addURL . '&eqds_bordereaux___categorie_raw=3' . '&eqds_bordereaux___film_id_raw=' . $d->rawData['eqds_planning_diffusion___film_id_raw'][0]. '&eqds_bordereaux___Date_de_debut_de_projection_raw=' . $d->rowData['eqds_planning_diffusion___date_projection_raw'];?>" title="<?php echo FText::_('COM_FABRIK_ADD');?>" class="toggle-addoption btn">
 
When you say it "doesn't do anything" ... is it being added to the query string, but just doesn't set the date in the form that pops up?

It may be that your date element configuration is overriding the query string. I have a feeling if you have "default to todays date", or some other options, that may override a query string.

Or do you mean nothing is being added to the query string?

-- hugh
 
I'm not sure why but, if you replace:

'&eqds_bordereaux___film_id_raw='

with

'&eqds_bordereaux___film_id='

I think it will work
 
For film_id, db join element, raw is needed
But for date element, you're right, without _raw it work.
Sorry, i was thinking have tried all possibility...
Thanks!
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top