'true', 'field_label' => '', 'field_name' => '', 'field_placeholder' => '', 'field_default_value' => '', 'field_instruction' => '', 'prepend' => '', 'append' => '', 'custom_fields_save' => 'post', 'field_required' => false, 'show_error_message' => true, ); } /** * Is meta field. * * Check if the field is a meta field. * * @since 1.0.0 */ public function is_meta_field(){ return true; } /** * Get widget title. * * Retrieve acf ele form widget title. * * @since 1.0.0 * @access public * * @return string Widget title. */ public function get_title() { return __( 'ACF Fields', 'frontend-admin' ); } /** * Get widget categories. * * Retrieve the list of categories the acf ele form widget belongs to. * * @since 1.0.0 * @access public * * @return array Widget categories. */ public function get_categories() { return array( 'fea-acf-fields' ); } public function set_controls() { $this->controls['_width']['default'] = '100%'; $this->register_field_section(); $this->register_validation_section(); //$this->register_style_tab_controls(); } public function register_field_section() { $this->add_control_group( 'fields_section', array( 'title' => __( 'Fields', 'frontend-admin' ), 'tab' => 'content', ) ); /* $this->add_control( 'show_field_label', array( 'label' => __( 'Show Labels', 'frontend-admin' ), 'type' => 'checkbox', 'default' => true, ) ); */ //select fields or field groups $this->add_control( 'fields_select', array( 'label' => __( 'Select Fields', 'frontend-admin' ), 'type' => 'select', 'optionsAjax' => [ 'action' => 'fea_get_acf_fields', 'groups' => true, ], 'multiple' => true, 'searchable' => true, 'placeholder' => esc_html__( 'Select Fields', 'frontend-admin' ), ) ); //exclude fields $this->add_control( 'exclude_fields', array( 'label' => __( 'Exclude Fields', 'frontend-admin' ), 'type' => 'select', 'optionsAjax' => [ 'action' => 'fea_get_acf_fields_exclude', 'groups' => false, ], 'multiple' => true, 'searchable' => true, 'placeholder' => esc_html__( 'Select Fields', 'frontend-admin' ), ) ); //display mode $this->add_control( 'field_display_mode', array( 'label' => __( 'Display Mode', 'frontend-admin' ), 'type' => 'select', 'default' => 'edit', 'options' => array( 'edit' => __( 'Edit', 'frontend-admin' ), 'read_only' => __( 'Read', 'frontend-admin' ), 'hidden' => __( 'Hidden', 'frontend-admin' ), ) ) ); //if read only, add "allow edit" option $this->add_control( 'field_inline_edit', array( 'label' => __( 'Inline Edit', 'frontend-admin' ), 'type' => 'checkbox', 'label_on' => __( 'Yes', 'frontend-admin' ), 'label_off' => __( 'No', 'frontend-admin' ), 'return_value' => 'true', 'default' => '', 'required' => array( 'field_display_mode', '=', 'read_only', ), ) ); //no value placeholder textarea $this->add_control( 'no_values_message', array( 'label' => __( 'No Value Message', 'frontend-admin' ), 'type' => 'textarea', 'label_block' => true, 'placeholder' => __( 'Undefined Value', 'frontend-admin' ), 'dynamic' => array( 'active' => true, ), 'required' => array( 'field_display_mode', '=', 'read_only', ), ) ); $this->field_specific_controls(); //$this->custom_fields_control(); } public function field_specific_controls(){ // Override in child class } public function field_specific_validation(){ // Override in child class } protected function register_validation_section() { $this->add_control_group( 'validation_section', array( 'title' => __( 'Validation', 'frontend-admin' ), 'tab' => 'content', ) ); //whether to show error message $this->add_control( 'show_error_message', array( 'label' => __( 'Show Error Message', 'frontend-admin' ), 'type' => 'checkbox', 'label_on' => __( 'Yes', 'frontend-admin' ), 'label_off' => __( 'No', 'frontend-admin' ), 'return_value' => 'true', 'default' => 'true', ) ); //message to show if field is required $this->add_control( 'field_required_message', array( 'label' => __( 'Required Message', 'frontend-admin' ), 'type' => 'text', 'label_block' => true, 'placeholder' => __( 'Field is required', 'frontend-admin' ), 'dynamic' => array( 'active' => true, ), ) ); //message to show if other validation fails $this->add_control( 'field_validation_message', array( 'label' => __( 'Validation Message', 'frontend-admin' ), 'type' => 'text', 'label_block' => true, 'placeholder' => __( 'Field is invalid', 'frontend-admin' ), 'dynamic' => array( 'active' => true, ), ) ); $this->field_specific_validation(); } public function register_style_tab_controls() { if ( ! isset( fea_instance()->pro_features ) ) { $this->start_controls_section( 'style_promo_section', array( 'label' => __( 'Styles', 'frontend-admin' ), 'tab' => 'style', ) ); $this->add_control( 'styles_promo', array( 'type' => 'raw_html', 'raw' => __( '
Go Pro to unlock styles.
', 'frontend-admin' ), 'content_classes' => 'acf-fields-note', ) ); } else { do_action( 'frontend_admin/style_tab_settings', $this ); } } /** * Render fields widget output on the frontend. * * @since 1.0.0 * @access protected */ public function render(){ global $fea_form, $fea_instance; $wg_id = $this->id; $settings = $this->settings; $field_ids = $settings['fields_select'] ?? []; $exclude_ids = $settings['exclude_fields'] ?? []; if( is_string( $field_ids ) ){ $field_ids = explode( ',', $field_ids ); } $this->set_attribute( '_root', 'class', 'acf-fields-wrapper' ); echo "