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

Feature #6349

Interceptor to modify GET/POST values

Added by Reinhard Führicht over 3 years ago. Updated over 2 years ago.

Status:Resolved Start date:2010-02-04
Priority:Could have Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
Votes: 0

Description

It would be pretty cool to have some kind of modifiers for the submitted values.

Think of something like this:

saveInterceptors {
  1.class = Interceptor_CombineValues
  1.config {
    name {
      fields {
        1 = firstname
        2 = lastname
      }
      seperator = , #Default should be space character
    }
  }
  2.class = Interceptor_TranslateValues
  2.config {
    translated_salutation {
      langKey = salutation_|
      field = salutation
    }
  }
}

The combined value for name could be used in Finisher_Mail for to_name, for example.

I am hoping for feedback. Maybe somebody has a better or additional ideas.

History

Updated by Fabien Udriot over 3 years ago

It looks interesting to have that feature, indeed.

I assume key "translated_salutation" and "name" from your example are usable as marker in the template file and in the TS (e.g insertion in the database) as well.

Thanks for your work.

Updated by Reinhard Führicht over 3 years ago

Fabien Udriot wrote:

I assume key "translated_salutation" and "name" from your example are usable as marker in the template file and in the TS (e.g insertion in the database) as well.

The modified values will be stored in $this->gp and therefore will be available in any other component called afterwards.
TypoScript will be a problem I guess, at least I don't know how it could be done.
Imagine:

config {
  user {
    to_name = TEXT
    to_name.data = GPVar:formhandler|name
  }
}

It would be really awesome to replace GPVar:[prefix]|[field] with values of the sanitized $this->gp and not of the unsanitized $_GET and $_POST.
But everytime Formhandler calls cObjGetSingle we would have to replace this values and don't even know where they are exactly:

# data
to_name = TEXT
to_name.data = GPVar:formhandler|name

# value
to_name = TEXT
to_name.data = GPVar:formhandler|name

# COA
to_name = COA
to_name.1 = TEXT
to_name.1.data = GPVar:formhandler|salutation
to_name.2 = TEXT
to_name.2.data = GPVar:formhandler|name

Do you have a solution for that?

Updated by Reinhard Führicht over 3 years ago

I implemented the following:

initInterceptors {
  1.class = Interceptor_CombineFields
  1.config {
    combineFields {
      combined {
        fields {
          1 = name
          2 = company
        }
        seperator = ,
        hideEmptyValues = 0
      }
    }
  }
  5.class = Interceptor_TranslateFields
  5.config {
    translateFields {
      translated {
        # Key in locallang file. "|" will be replaced with the content of the given form field.
        langKey = label_salutation_|
        field = salutation
      }
    }
  }
}

What do you think?

I also thought about providing the ability to use the sanitized GET/POST values in TypoScript. I only came up with the idea to use new syntax and do some post processing in Formhandler.

Example:

user {
  to_email = email
  subject = TEXT
  subject.value = {formhandler:subject}
}

After calling cObjGetSingle on the TEXT object, we would have to replace all {formhandler:xyz} with the content of the according form field "xyz".
Therefore it would be nice to place all cObjGetSingle calls in a wrapper method in the StaticFuncs to have a single point in the code where the post processing happens.
Allthough I don't think this is the best solution, I wasn't able to find a better one. So please enlight me, if you come up with something else. :-)

Updated by Reinhard Führicht over 3 years ago

Committed the 2 new interceptors to trunk.
Moved the issue about accessing $this->gp via TypoScript to a new issue (Issue #6421).

Updated by Reinhard Führicht about 3 years ago

  • Status changed from New to Resolved

Also available in: Atom PDF