product_ask_questions_form¶
The product_ask_questions_form
macro is used to render a form allowing to ask questions related to a given product.
Definition¶
Input parameters¶
options¶
object
represents an object of product ask questions form options and consists of the following fields:
Option key | Type | Default | Required | Description |
---|---|---|---|---|
options.instanceId | string |
"" | yes | Unique identifier commonly provided by a special module variable moduleInstance |
Example¶
In this example we render a regular product ask questions form for a certain product. While using this macro inside a module we can pass a moduleInstance
as an instanceId
parameter.
{% from "@macros/product_ask_questions_form.twig" import product_ask_questions_form %}
{{ product_ask_questions_form({
instanceId: moduleInstance
}) }}
Macro source code¶
{% macro product_ask_questions_form(options) %}
{% from "@macros/control_textarea.twig" import control_textarea %}
{% from "@macros/control_input.twig" import control_input %}
<div class="form__additional-info">
<em>
{{ translate('Required fields are marked with') }} -
<span class="form__additional-info_secondary">*</span>
</em>
</div>
{{
control_input({
name: 'mail',
label: translate('Your e-mail address'),
id: "product-ask-questions-email-#{options.instanceId}",
controlValidators: {
required: true,
email: true
},
type: 'email'
})
}}
{{
control_textarea({
id: "product-ask-questions-question-#{options.instanceId}",
name: 'question',
label: translate('Your question'),
controlValidators: {
required: true
}
})
}}
<div class="grid__row grid__row_xs-hright mb-xs-4">
<div class="grid__col grid__col_xs-12">
<button
type="submit"
class="modal__btn btn btn_primary btn_full-width"
>
{{ translate('Send') }}
</button>
</div>
</div>
{% endmacro %}