AnsPress_Form::text_field( array $field = array(), string $type = 'text' )
Description #
Output text fields.
Parameters #
- $fieldarray (Optional) Field. Default value: array()
- $typestring (Optional) Type of field. Default value: 'text'
Source #
File: includes/class/form.php
private function text_field( $field = array(), $type = 'text' ) { if ( isset( $field['label'] ) ) { $this->label(); } $placeholder = $this->placeholder(); $autocomplete = isset( $field['autocomplete'] ) ? ' autocomplete="off"' : ''; $this->output .= '<div class="ap-form-fields-in">'; if ( ! isset( $field['repeatable'] ) || ! $field['repeatable'] ) { $this->output .= '<input id="' . $field['name'] . '" type="' . $type . '" class="ap-form-control" value="' . $field['value'] . '" name="' . $field['name'] . '"' . $placeholder . ' ' . $this->attr( $field ) . $autocomplete . ' />'; if ( 'password' === $type ) { $this->output .= '<input id="' . $field['name'] . '-1" type="' . $type . '" class="ap-form-control" value="' . $field['value'] . '" name="' . $field['name'] . '-1" placeholder="' . __( 'Repeat your password', 'anspress-question-answer' ).'" ' . $this->attr( $field ) . $autocomplete . ' />'; } } else { if ( ! empty( $field['value'] ) && is_array( $field['value'] ) ) { $this->output .= '<div id="ap-repeat-c-' . $field['name'] . '" class="ap-repeatbable-field">'; foreach ( $field['value'] as $k => $rep_f ) { $this->output .= '<div id="ap_text_rep_' . $field['name'] . '_' . $k . '" class="ap-repeatbable-field"><input id="' . $field['name'] . '_' . $k . '" type="text" class="ap-form-control ap-repeatable-text" value="' . $rep_f . '" name="' . $field['name'] . '[' . $k . ']"' . $placeholder . ' ' . $this->attr( $field ) . $autocomplete . ' />'; $this->output .= '<button data-action="ap_delete_field" type="button" data-toggle="'. $field['name'] . '_' . $k . '">' . __( 'Delete', 'anspress-question-answer' ) . '</button>'; $this->output .= '</div>'; } $this->output .= '</div>'; $this->output .= '<div id="ap-repeatbable-field-' . $field['name'] . '" class="ap-reapt-field-copy">'; $this->output .= '<div id="ap_text_rep_' . $field['name'] . '_#" class="ap-repeatbable-field"><input id="' . $field['name'] . '_#" type="text" class="ap-form-control ap-repeatable-text" value="" name="' . $field['name'] . '[#]"' . $placeholder . ' ' . $this->attr( $field ) . $autocomplete . ' />'; $this->output .= '<button data-action="ap_delete_field" type="button" data-toggle="' . $field['name'] . '_#">' . __( 'Delete', 'anspress-question-answer' ) . '</button>'; $this->output .= '</div></div>'; $this->output .= '<button data-action="ap_add_field" type="button" data-field="ap-repeat-c-' . $field['name'] . '" data-copy="ap-repeatbable-field-' . $field['name'] . '">' . __( 'Add more', 'anspress-question-answer' ) . '</button>'; } } $this->error_messages(); if ( ! $this->field['show_desc_tip'] ) { $this->desc(); } $this->output .= '</div>'; }
Expand full source code Collapse full source code View on GitHub: includes/class/form.php:275
Add your comment