3

I have a FE Plugin which uses a FlexForm MyExtFlexForm which is used to set certain configurations like limit or SourcePage etc..

In my controller action list I get these settings using $this->settings. Works fine till now.

Now, I make AJAX calls to action update and I need to use the same settings which have been set earlier through the FlexForm for the FE plugin on this page. $this->settings does not show anything.

I checked $GLOBALS['TSFE']->tmpl->setup['plugin']['MyExt.']['settings.'] and none of the settings defined in FlexForm show here.

How do I solve this issue?

EDIT:

My sample Flexform looks like this:

<sheets>
        <sDEF>
            <ROOT>
                <TCEforms>
                    <sheetTitle>View Settings</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <switchableControllerActions>
                        <TCEforms>
                            <label>Select</label>
                            <config>
                                <type>select</type>
                                <items>
                                    <numIndex index="0">
                                        <numIndex index="0">MyFunction</numIndex>
                                        <numIndex index="1">MyExt->list</numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </switchableControllerActions>

                    <settings.flexform.limit>
                        <TCEforms>
                            <label>Number of items to be displayed</label>
                            <config>
                                <type>input</type>
                                <size>10</size>
                            </config>
                        </TCEforms>
                    </settings.flexform.limit>
                </el>
            </ROOT>
        </sDEF>
    </sheets>

Then I make an AJAX call to my controller action and print this $this->settings , shows no settings.

dora
  • 1,314
  • 2
  • 22
  • 38
  • Is that common AJAX or eID? – biesior Oct 31 '13 at 11:42
  • It's common AJAX. Not eID. – dora Oct 31 '13 at 11:43
  • I don't get there's nothing unusual when calling a page with AJAX or common GET, I can't reproduce your problem, maybe there's something about your TS for these request? – biesior Oct 31 '13 at 12:19
  • The TS seems fine as well. The request calls are successfully going. My TS for ajax is pretty much like this http://stackoverflow.com/questions/19688172/ajax-calls-to-typo3-extension-not-working – dora Oct 31 '13 at 12:41
  • Maybe this can help as well: https://stackoverflow.com/questions/48743890/how-can-i-add-an-action-to-a-typo3-frontend-plugin/48743891#48743891 – giraff Feb 12 '18 at 10:12
  • IF you are calling ajax using pagenum or eID it can be pass like this: ``settings < plugin.tx__.settings`` – Ashish Patel Jan 06 '21 at 10:25

2 Answers2

4

I just came across a solution: https://forum.typo3.org/index.php/t/194022/eigener-extbase-controller-keine-flexform-werte

I was including the plugin like this:

AJAX_PAGE = PAGE
AJAX_PAGE {
    typeNum = 2

    10 < tt_content.list.20.myPlugin

    config {
        disableAllHeaderCode = 1
        xhtml_cleaning = 0
        admPanel = 0
        debug = 0
        no_cache = 1
    }
}

In order to load the settings correctly it should be:

AJAX_PAGE = PAGE
AJAX_PAGE {
    typeNum = 2

    10 < styles.content.get
    10 {
        select.where = colpos = 0
        select.andWhere = list_type='myPlugin'
    }

    config {
        disableAllHeaderCode = 1
        xhtml_cleaning = 0
        admPanel = 0
        debug = 0
        no_cache = 1
    }
}
maechler
  • 1,257
  • 13
  • 18
3

The easiest solution is proper naming fields in FlexForm ie, if your field will be prefixed with settings. it will be visible in $this->settings array:

<settings.myField>
    <TCEforms>
        <label>My very special setting</label>
        <config>
            <type>input</type>
        </config>
    </TCEforms>
</settings.myField>

Controller:

$mySetting = $this->settings['myField'];

On the other hand if you're planning to merge TS settings with FlexForm settings you can prefix it additionaly with some other word like: <settings.flexform.myField> and then access it:

$fromTypoScript = $this->settings['myField'];
$fromFlexform   = $this->settings['flexform']['myField'];

// or...
$myMergedSetting = (!$this->settings['flexform']['myField'])
                   ? $this->settings['myField']
                   : $this->settings['flexform']['myField'];
biesior
  • 55,576
  • 10
  • 125
  • 182
  • 5
    The problem is while making AJAX calls. I am able to access the settings otherwise. Edited my question with the FlexForm. Thanks – dora Oct 31 '13 at 10:25