CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

Support #30383

Field values in TS

Added by Rainer Becker over 1 year ago. Updated over 1 year ago.

Status:Closed Start date:2011-09-28
Priority:Should have Due date:
Assignee:Reinhard Führicht % Done:

0%

Category:-
Target version:Stable v1.0
Votes: 0

Description

Is there a way to get the current field values into the TS setup?
Like:

plugin.Tx_Formhandler.settings.predef.myForm{
   markers {
      price = TEXT
      price.value = 0
      price.override = 10.99
      price.override.if.isTrue.field = field_product1
   }
}

I would like to calculate a sum based on the ticked checkboxes.

History

Updated by Reinhard Führicht over 1 year ago

  • Status changed from New to Accepted
  • Assignee set to Reinhard Führicht
  • Target version set to Stable v1.0

Formhandler hooks into stdWrap:

public function stdWrapPreProcess($content, array $configuration, tslib_cObj &$parentObject) {
    if(intval($configuration['sanitize']) === 1) {
        $globals = Tx_Formhandler_Globals::getInstance();
        $this->originalGET = $_GET;
        $this->originalPOST = $_POST;
        $prefix = $globals->getFormValuesPrefix();
        $_GET[$prefix] = $globals->getGP();
        $_POST[$prefix] = $globals->getGP();
    }
    return $content;
}

So a setup like this should work:

markers {
  price = TEXT
  price.value = 0
  price.override = 10.99
  price.override.if.isTrue.stdWrap.data = GP:formhandler|field_product1
  price.override.if.isTrue.stdWrap.sanitize = 1
}

Looking at the hook, it seems that this is only possible if a "formValuesPrefix" is set in TypoScript and used in the template.
This is a bug. I will open a separate issue for that.

Updated by Reinhard Führicht over 1 year ago

Issue #30388 deals with the formValuesPrefix problem.

Updated by Rainer Becker over 1 year ago

This works fine - for scalar values. Since getText->GP won’t work on arrays it would be cool to put value arrays (of radio buttons or checkboxes) as comma separated string into the GP-Array. That way it could be accessed (and iterated) with TS.

Updated by Reinhard Führicht over 1 year ago

Rainer Becker wrote:

This works fine - for scalar values. Since getText->GP won’t work on arrays it would be cool to put value arrays (of radio buttons or checkboxes) as comma separated string into the GP-Array. That way it could be accessed (and iterated) with TS.

I agree that this would be cool, but that is a limitation of Typoscript itself.
The main goal is to make Formhandler GET/POST parameters accessible in Typoscript. This is exactly what the hook does.

I do not want to put additional processing stuff in there. To be able to handle arrays, you would have to write a userFunc and access the parameters there, just like you would have to in any other "part" of your Typoscript setup. I think it is a good thing, that Formhandler doesn't break this "consistency".

Updated by Rainer Becker over 1 year ago

I agree. I can even access arrays now, but the values are gone between multiple steps because the GP array is not filled with values from step1 if I return from step2 to step1. Does this mean I have to write an interceptor class which loads certain values in registers? If yes, I think an easier solution could/should be found for this task.

Updated by Reinhard Führicht over 1 year ago

I will do some testing.

Updated by Rainer Becker over 1 year ago

The transport of GP array through steps works properly. I misconfigured the defaultvalues for checkboxes (didn’t now that defaultValue must be a cObj). So this one can be closed - sorry for my misleading note.

Updated by Reinhard Führicht over 1 year ago

  • Status changed from Accepted to Closed

Also available in: Atom PDF