• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

when a list is displayed on form, methods for handing form saving

skyrun

Active Member
i have a list displayed on a form (through the content plugin).

only problem is that if i click to display, edit or add to the list, then the browser does that and doesn't save any changes i may have made to the form first.

here are three approaches i have considered to solve this that i am wondering if are possible on fabrik (i'm sure there are other approaches):
  1. display the add/edit/details for the embedded list in a modal box over top of the form so the form/DOM is still intact underneath.
  2. make the add/edit/details links on the embedded list open in a new tab.
  3. have fabrik ask 'Save changes to [form name]?' before going off of any form on any page. This seems like a good enhancement all around. An 'are you sure' when leaving the page if you leave it using the window.xxxx method or the user changing the url on the page vs. when the user presses a button like save or 'go back' on fabrik. wouldn't even have to check to see if there were changes, could do it every time you are leaving a form page in a 'forced' way.
i don't know how to implement any of these 3... any recommendations?
 
for 1.
Did you try a list with ajaxfied links? This should open add/edit/details in a popup.
 
yes, i have ajaxified links set to yes on the list that is displayed within the form. however when the list is displayed that way, it does not work. no .js, but does nothing (ie it opens in the same tab vs. a modal box when you click +add/edit etc as if ajaxify were set to no)

also note that if i open the list natively (ie not on the form) that it does work. it even updates the list on the screen after adding and editing. so it's the perfect solution for this but doesn't seem to function when run on a form OR when run from the content plugin (which is how i include it on the form.

if you have the fabrik logon for my devl site, you can see this here:
https://testlocation.skyrun.com/skytrax-manage/work-orders/form/180/820
on the 'notes' tab.
 
Last edited:
I just tested and it's working fine on my site.

List links ajaxfied, list in form intro, Protostar template.
I can put text is form fields, add/edit/display list records -> the edited form fields are still showing the new text and the form can be saved.

I can't log in on your testlocation.
Where did you put the content plugin? With a standard list template (using the <form tag) you can only put it into intro/outro.
 
i wanted the list on a new tab, so i have included it in the template. i couldn't figure out how to add a tab (which is a group for the other 4) without adding html to the form template.

so at the end of my template, i added this:

Code:
endforeach;

// BVC ADD NEW TAB for notes list
    $tabId = $this->form->id . '_' . (int) $this->rowid . '_' . $i;
    $notestabId = $tabId;
    $is_err = false;
    $tab = new stdClass;
    $tab->class = $i === 0 ? 'active ' . $err_class : $err_class;
    $tab->css = $group->css;
    $tab->href = 'group-tab' . $tabId;
    $tab->id = 'group999_tab';
    $tab->label = 'Notes';
    $tabs[] = $tab;
    $i++;
// BVC END ADD

    echo FabrikHelperHTML::getLayout('fabrik-tabs')->render((object) array('tabs' => $tabs));
 
So where are you loading the content plugin?
I assume somewhere after the 2nd loop (tab-content)?

As I've said:
You can't load a list inside the form's <form tag, i.e. you can't load it between line 42 to 156 in bootstraps_tabs/default.php
because this will create nested form tags (the list template is also doing <form>...</form>)
which will break the whole thing.
 
ok. getting closer.

yes, i had this a little farther down:
Code:
                </fieldset>
                <?php
            endforeach;
            // next part, add content to notes tab
            ?>
        </div>
        </form>
        <div role="tabpanel" class="tab-pane" id="group-tab<?php echo $notestabId; ?>">
            <fieldset class="tabpane" id="group999_tab" style="">
                <legend class="legend">Notes</legend>
                {fabrik view=list embeddedForm=1 id=177 srms_work_order_notes___wo_id=<?php echo $this->rowid; ?>}
            </fieldset>
        </div>
        <?php // end addition    ?>
    </div>
</div>
</div>
<?php if ($model->editable) : ?>
    <div class="fabrikHiddenFields">
        <?php echo $this->hiddenFields; ?>
    </div>
    <?php
endif;
echo $this->pluginbottom;
echo $this->loadTemplate('actions');
?>
<?php // was </form> no php ?>
<?php
echo $form->outro;
echo $this->pluginend;
echo FabrikHelperHTML::keepalive();
?>

in this hack-attempt, i commented out the </form> that was at the end of the loop and added it up after the 4th tab and now the 'add' button opens the form in a modal window, but the form no longer works adn there are no save buttons showing on the modal window.

that's because the buttons at the bottom are outside of the loop of course and are no longer in the </form>.

knew better, but tried anyway to end the form with </form>, display the new list and then start a new <form>. but that yielded an invalid token error message.

so i don't think it's going to be possible to include the list on a tab on the form since there is no way that i can think of to have the list be on a tab that is on the form and also outside of the oveall <form></form>
 
trying to figure out if it can be done in an iframe somehow...

running into an issue embedding the content plugin within an iframe. trying:
Code:
<iframe src="data:text/html,{fabrik view=list id=177 srms_work_order_notes___wo_id=<?php echo $this->rowid; ?>}"></iframe>
but it's not working... its loading the list html because the intro is showing (not correctly utf-8 encoded). but there are encoding issues or something... looks like this:
upload_2018-9-13_14-50-9.png
so let me know if you have any ideas to display a list within a form and still allow the ajaxify links.
 
another note. when i put the lists in the outtro (i assume same as 'footer' on the form), the EDIT button does work correctly to ajaxify, but the '+add' button still displays in the same window.

any other ideas to be able to have a list in a form that doesn't mess up the saving of the form?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top