[CLOSED] Database join Element | Dropdown | show or hide options according the repeated group ID

Status
Not open for further replies.

marcq

Member
Hi,

I have created a list|form which enable trainer to create training curriculum.

The form contains several groups with different kind of information's they need to fill-in tabs Elements like Objective|Content of the training, Session|Pricing of the training etc.

I one of this group, Session|Pricing which is a repeat group, I would like to enable the teacher to insert the possible different exam dates among which the trainee will be able to pick one date.

I have created a database join dropdown element that the trainer can fill-in with the possible exam dates by using the add options possibility.

It is working well, but the problem I have is that the filled-in exam dates should only be displayed for the specific session (repeat group ID) and not for all the other sessions:
upload_2017-4-11_18-12-58.png

Is there a way to do this ?

Thanks in advance for your support and tips,

Cheers,

Marc
 
Last edited:
OK, so if I'm understanding you correctly, you mean that when you use the + button to add a new date from a given repeat, you then only want that option to only show when display the join options on that repeat.

There's nothing built in to do that.

It might be possible, with a caveat, and a little custom code. The code would have to involve overriding this layout file:

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

... around line 29 where it builds the link for the + button:

PHP:
    <a href="<?php echo $d->addURL; ?>" title="<?php echo FText::_('COM_FABRIK_ADD');?>" class="toggle-addoption btn">
        <?php echo FabrikHelperHTML::image('plus', 'form', @$d->tmpl, array('alt' => FText::_('COM_FABRIK_SELECT'))); ?>
    </a>

... you'd have to add to that $d->addURL, something like ...

echo $d->addURL . '&amp;your_date_table___session_id=' . $d->rowData['your_repeat_session_table___id_raw'][$d->repeatCounter];

Where 'your_date_table___session_id' would be a field you add in the date form to hold the "parent" session ID. And 'your_repeat_session_table___id' would be the existing 'id' of the repeated session table.

HOWEVER ... this would only work for existing session repeats. You wouldn't be able to add a new session repeat on the form, and (withuot saving the form) add a date for it. That's because until the form is saved, those repeats don't have an ID. That gets assigned as the form is saved, and the new repeat rgoup is written out as a row in the joined table.

So when adding a new session, you'd have to save the main form, then add dates for it.

Also ... I'd need to commit a small change to the code, to make $d->repeatCounter available in the layout data.

Then ... you'd need to add a WHERE clause in the join for the dates, like "{thistable}.session_id = '{your_repeat_session_table___id_raw}'.

So ... yes, it's (kind of) possible, but not trivial.

-- hugh
 
Thanks Hugh for your explanation and solution, would be great if you could commit the small change.

Concerning the id, I will save the form repeat group as soon as a value is written into the 'Intitul? de la session' field element.

My only issue with this, is that after saving the form, I loose the tab focus. Indeed, I continue to struggle with the lost of tab focus tackled in the following thread :

http://fabrikar.com/forums/index.ph...fter-apply-focus-go-to-to-specific-tab.46432/

I tried several JavaScript solutions provided by 'stackoverflow' forum threads concerning bootstrap template and how to keep the focus but none works.

I would appreciate if someone reads this thread and having solved this kind of issue could share his findings and solution.

Thanks again for your didactic way and time taken to explain things, it is much appreciated.

Cheers, marc
 
I would like to enable the user to delete the previous inserted exam dates and of course I need to filter the Exam dates which belongs to the repeat group id.

I tried in the list of the form several prefilters which doesn't exclude the Exam dates which doesn't belong to the appropriate repeat group :

How can I achieve this ?

Thanks a lot in advance for your support,

Cheers,

Marc

upload_2017-4-12_21-33-50.png
 

Attachments

  • upload_2017-4-12_21-22-39.png
    upload_2017-4-12_21-22-39.png
    155.5 KB · Views: 40
You'll probably have to do something similar with the $chooseUrl in that layout. The problem being that the link to pop up the choose window doesn't include that repeat group ID, so there's no way of filtering for it, as-is.

So add a query string for the repeat group id element. If you are lucky, just adding the same thing you did to the other url might just work, as a query string filter. Or you may have to add a specific prefilter for it, with whatever query string name you give it as the placeholder in the prefilter value.

-- hugh
 
Hi Hugh,
It is to complex for my knowledge, could you please develop a little bit more step by step ?
Thanks in advance for your understanding, cheers, marc
 
Hi,

Closed to soon this thread.

There is still an issue concerning the first part of this thread (#1 to #5).

When I'm editing an existing record, add in the Sessions & Tarifs tab a new session, add among other a new row and enter new exam dates into the databasejoin dropdown element and save or apply the form, the exam dates of all dropdown elements vanished, please see video :

https://www.screencast.com/t/RpTz7kKWz

Would be great if you could have a look, all information (access to front and backend, to phpmyadmin etc.) can be found under MySites | Site Name GPRH.

Thanks in advance and cheers, marc
 
This is moving beyond subscription support into custom coding. I can give you advice and code snippets, but if you need me to login and debug custom code, that's billable hours.
 
Thanks Hugh,

my problem happens when I'm adding a new row into the repeat group Sessions & Tarifs:

Please see this video which show what's happen :

https://www.screencast.com/t/x6X0XHlbsU

1. When I'm inserting a new row, the dates already present into the databasejoin dropdown element are replicated into the new rows databasejoin dropdown (dropdown should be empty since the new row as not been saved)

2. When I'm applying the change, then both databasejoint dropdown are empty.

3. If I'm deleting the second row and apply the change, then the databasejoin dropdown content is displayed.

Parameters of my database join Element are :

upload_2017-5-1_21-50-23.png

{thistable}.rg_id = '{gprh_fabrik_user_training_124_repeat___id_raw}'

with this I'm trying to restrict the content of the dropdown with the dates related to the row.

I tried this too :

WHERE {thistable}.rg_id IN (SELECT id FROM gprh_fabrik_user_training_124_repeat WHERE id = {thistable}.rg_id)

upload_2017-5-1_21-50-1.png

upload_2017-5-1_21-50-32.png

Thank you in advance for you support.

Marc
 
Last edited:
Do someone have a clue how to solve this ? I'm stuck and need to find a solution. Thanks in advance for advice.
 
As I said in my last response, this is beyond the scope of subscription support. If you'd like to discuss hourly rates, contact me on Skype (hugh dot messenger at gmail dot com).

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top