PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.4
JetFormBuilder — Dynamic Blocks Form Builder v3.5.4
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / block-parsers / fields / repeater-field-parser.php
jetformbuilder / modules / block-parsers / fields Last commit date
date-field-parser.php 2 years ago datetime-field-parser.php 2 years ago datetime-trait.php 2 years ago default-parser.php 2 years ago hidden-field-parser.php 2 years ago media-field-parser.php 1 year ago repeater-field-parser.php 2 years ago text-field-parser.php 2 years ago wysiwyg-field-parser.php 2 years ago
repeater-field-parser.php
68 lines
1 <?php
2
3
4 namespace JFB_Modules\Block_Parsers\Fields;
5
6 use Jet_Form_Builder\Request\Exceptions\Sanitize_Value_Exception;
7 use JFB_Modules\Block_Parsers\Field_Data_Parser;
8
9 // If this file is called directly, abort.
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 class Repeater_Field_Parser extends Field_Data_Parser {
15
16 public function type() {
17 return 'repeater-field';
18 }
19
20 /**
21 * @return int|void
22 * @throws Sanitize_Value_Exception
23 */
24 public function get_response() {
25 $indexes = $this->get_indexes();
26
27 if ( ! $indexes ) {
28 return '';
29 }
30
31 if ( ! $this->get_inner_template() ) {
32 return -1;
33 }
34
35 foreach ( $indexes as $index ) {
36 $context = clone $this->get_inner_template();
37 $context->set_index_in_parent( $this->add_inner( $context ) );
38
39 $context->set_request( $this->value[ $index ] ?? array() )
40 ->set_files( $this->file[ $index ] ?? array() );
41
42 $context->apply();
43 }
44
45 $this->set_file( false );
46
47 return count( $indexes );
48 }
49
50 protected function get_indexes(): array {
51 if ( ! is_array( $this->value ) ) {
52 $this->value = array();
53 }
54 if ( ! is_array( $this->file ) ) {
55 $this->file = array();
56 }
57
58 $indexes = array_keys( $this->value );
59 $file_indexes = array_keys( $this->file );
60
61 /**
62 * @see https://github.com/Crocoblock/issues-tracker/issues/2095
63 */
64 return max( $indexes, $file_indexes );
65 }
66
67 }
68