Descrição
Este plugin adiciona grupos de campos repetíveis no Contact Form 7.
NOTE: Tested with Contact Form 7 5.1.6.
Como usar
Formulário
Envolva os campos desejados com [field_group id_do_seu_grupo_aqui][/field_group]
. O shortcode aceita parâmetros adicionais, tanto no formato de shortcode do WP quanto no formato de parâmetros de campos do CF7.
Exemplo:
[field_group emails id="emails-groups" tabindex:1]
<label>Your Email (required)[email* your-email]</label>
[radio your-radio use_label_element default:1 "radio 1" "radio 2" "radio 3"]
[select* your-menu include_blank "option1" "option 2"]
[checkbox* your-checkbox "check 1" "check 2"]
[/field_group]
Nas configurações de e-mail, envolva os campos com o id do seu grupo. Você também pode usar a tag [group_index]
para exibir o índice do grupo e um __<NÚMERO>
adicionar para exibir um campo com índice específico.
Exemplo:
The second email entered by the user was: [your-email__2]
These were the groups:
[emails]
GROUP #[group_index]
Checkbox: [your-checkbox]
E-mail: [your-email]
Radio: [your-radio]
Select: [your-menu]
[/emails]
Customizing the add and remove buttons
You can add filters to your theme to customize the add and remove buttons.
Example
// In your theme's functions.php
function customize_add_button_atts( $attributes ) {
return array_merge( $attributes, array(
'text' => 'Add Entry',
) );
}
add_filter( 'wpcf7_field_group_add_button_atts', 'customize_add_button_atts' );
The available filters are:
wpcf7_field_group_add_button_atts
Filters the add button attributes.
Parameters:
* $attributes: Array of attributes for the add button. Keys:
* additional_classes
: css class(es) to add to the button
* text
: text used for the button
Return value: array of button attributes
wpcf7_field_group_add_button
Filters the add button HTML.
Parameters:
* $html: Default add button HTML
Return value: button HTML
wpcf7_field_group_remove_button_atts
Filters the remove button attributes.
Parameters:
* $attributes: Array of attributes for the remove button. Keys:
* additional_classes
: css class(es) to add to the button
* text
: text used for the button
Return value: array of button attributes
wpcf7_field_group_remove_button
Filters the remove button HTML.
Parameters:
* $html: Default remove button HTML
Return value: button HTML
Contribua
Você pode contribuir com código, relatando problemas ou dando ideias no repositório no GitHub.
Se você gostou, deixe uma avaliação 🙂
FAQ
- É possível alterar os botões de adicionar e remover?
-
Sim. Você pode usar os filtros
wpcf7_field_group_add_button_atts
,wpcf7_field_group_add_button
,wpcf7_field_group_remove_button
ewpcf7_field_group_remove_button
como mostrado acima. Meus agradecimentos para @berniegp. - How can I display the group index number in the form?
-
You’ll have to use the
wpcf7-field-groups/change
jQuery event.In the Form tab, add an element to hold the group index. In this example, it’ll be a
<span>
with thegroup-index
class:[field_group emails id="emails-groups" tabindex:1] <p>Group #<span class="group-index"></span></p> <label>Your Email (required)[email* your-email]</label> [radio your-radio use_label_element default:1 "radio 1" "radio 2" "radio 3"] [select* your-menu include_blank "option1" "option 2"] [checkbox* your-checkbox "check 1" "check 2"] [/field_group]
E então, será preciso adicionar isto ao seu código JavaScript:
jQuery( function( $ ) { $( '.wpcf7-field-groups' ).on( 'wpcf7-field-groups/change', function() { var $groups = $( this ).find( '.group-index' ); $groups.each( function() { $( this ).text( $groups.index( this ) + 1 ); } ); } ).trigger( 'wpcf7-field-groups/change' ); } );
Você pode adicionar este JavaScript alterando o seu tema ou usando um plugin como o Simple Custom CSS and JS.
Avaliações
Colaboradores e desenvolvedores
“Contact Form 7 – Campos repetíveis” é um software com código aberto. As seguintes pessoas contribuíram para este plugin.
Colaboradores“Contact Form 7 – Campos repetíveis” foi traduzido para 4 localizações. Agradecemos aos tradutores por suas contribuições.
Traduzir “Contact Form 7 – Campos repetíveis” para o seu idioma.
Interessado no desenvolvimento?
Navegue pelo código, dê uma olhada no repositório SVN ou assine o registro de desenvolvimento via RSS.
Registro de alterações
Para a lista completa leia o changelog.txt
1.1.3
- Update WP
Tested up to
field - Apply WP Coding Standards
- Fix a small sanitation problem
1.1.2
- Fix Exclusive Checkboxes
1.1.1
- Add compatibility to formatted dates (
[_format_{field name} "{date format}"]
) - DEV: Copy data and events while cloning a new group (JS)
- DEV: Pass
$new_group
as an extra param for thewpcf7-field-groups/added
event. - DEV: Apply some WPCS rules and add a CF7_REPEATABLE_FIELDS_VERSION const (may affect JS cache)
1.1
- Replace groups in mail 2 field