-
Notifications
You must be signed in to change notification settings - Fork 627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically append namespace to "getQueryParam" if used inside "namespace" tag #5936
Comments
This is what the namespaceInputName filter is for: {{ craft.app.request.getQueryParam('someName'|namespaceInputName) }} (As long as you put that code within your |
@brandonkelly That's why |
You’re right, sorry. Will reopen for now, but I think the solution here is maybe to make |
@brandonkelly |
Actually this isn’t going to be possible at all, because Craft can’t always reliably know what a parameter name is going to end up as, solely based on its form input name. For example, let’s say the input name is That makes me think this isn’t a good idea to address directly in Craft, but you could hack around it using a combination of namespaceInputName, replace, and trim: {% macro namespaceParam(param) %}
{{- param|namespaceInputName|replace('/[\\[\\]]+/', '.')|trim('.') -}}
{% endmacro %}
{{ craft.app.request.getQueryParam(_self.namespaceParam('someParam')) }} |
Today I tested
{% namespace %}
tag. I create simple form with input which would be filled with content of URL param corresponding to inputsname
:Unfortunetly it did not worked. I needed to append namespace manually to
getQueryParam
:I have proposal that would allow avoiding that - adding third param to
getQueryParam
that would automatically append namespace togetQueryParam
function if it was used withinnamespace
tag.The text was updated successfully, but these errors were encountered: