Repeatable::prepare()
Description #
Prepare field.
Source #
File: lib/form/class-repeatable.php
protected function prepare() { $this->args = wp_parse_args( $this->args, array( 'label' => __( 'AnsPress Repeatable Field', 'anspress-question-answer' ), ) ); $this->main_fields = $this->args['fields']; unset( $this->args['fields'] ); $value_count = ! empty( $this->value() ) ? count( $this->value() ) : $this->get_groups_count() + 1; $this->total_items = $value_count > 0 ? $value_count : 1; $new_fields = array(); $i = 0; while ( $this->total_items > $i ) { ++$i; $this->args['fields'][ $i ] = array( 'label' => $this->get( 'label' ) . ' #' . number_format_i18n( $i ), 'fields' => $this->main_fields, 'type' => 'group', 'delete_button' => true, ); } $this->child = new Form( $this->form_name, $this->args ); $this->child->prepare(); // Call parent prepare(). parent::prepare(); // Make sure all text field are sanitized. $this->sanitize_cb = array_merge( array( 'array_remove_empty' ), $this->sanitize_cb ); }
Expand full source code Collapse full source code View on GitHub: lib/form/class-repeatable.php:55
Add your comment