1

I use tx_news to show jobs records (list and detail view). On the detail page of a record I have a link to a application form:

Detail.html

<f:link.page pageUid="21" class="btn btn-primary">Application</f:link.page>

... for the application form I use powermail. Here I have a select and I fill the select option values with the job records like this:

lib.joboptions = CONTENT
lib.joboptions {
        table = tx_news_domain_model_news
        select.pidInList = 156
        renderObj = COA
        renderObj {
                10 = TEXT
                10.field = title

                20 = TEXT
                20.value = |

                30 = TEXT
                30.field = uid

                stdWrap.wrap = |[\n]
        }
}   

https://docs.typo3.org/typo3cms/extensions/powermail/ForAdministrators/BestPractice/PrefillField/Index.html

... but how can I pre-select the select with the specific job record id when clicking on the 'Application' button?

Edit:

... I used js and localStorage as a workaround ... it works but only for one language. If I'm on the application form and switch languages ... the options in the select have a different uid and subsequently the select is unselected

$('.btn-apply').on('click', function() {
    localStorage.setItem("varJobID", jobID);
}); 
$('#powermail_field_jobs, #powermail_field_job').val(localStorage.getItem('varJobID'));
Philipp M
  • 3,306
  • 5
  • 36
  • 90

2 Answers2

0

In the manual (see https://docs.typo3.org/typo3cms/extensions/powermail/ForAdministrators/BestPractice/PrefillField/Index.html#example-2) there is an example how to use a preselection.

E.g.:

lib.options = TEXT
lib.options.value = Red shoes|red[\n]Blue shoes|blue|*[\n]Pink shoes|pink
Alex Kellner
  • 1,263
  • 6
  • 11
  • But how can I tell the select to preselect the previous job record the user wants to apply for (the 'application' button clicked)? ... and preselect this record also when doing a language switch ... – Philipp M Jun 22 '18 at 16:10
0

You can use the same strategy that is used to put the news title for example in a breadcrumb menu: pass the id of the news record (see How to set breadcrumb for tx_news TYPO3)

Let's sat that

  • you have a field in your form called {job} (an input field, but it could as well be an hidden field)
  • in the link to your powermail form page, pass the news record ID as a parameter (&jobid=XX) where XX is the news record ID

Then your TypoScript for the prefill will be:

plugin.tx_powermail.settings.setup.prefill {
job = RECORDS
job {
    if.isTrue.data = GP:jobid
    dontCheckPid = 1
    tables = tx_news_domain_model_news
    source.data = GP:jobid
    source.intval = 1
    conf.tx_news_domain_model_news = TEXT
    conf.tx_news_domain_model_news {
        field = title
        htmlSpecialChars = 1
    }
}