get_form_type() == 'quiz-form' && class_exists('\MetForm_Pro\Base\Package') ) { $this->start_controls_section( 'quiz_section', [ 'tab' => Controls_Manager::TAB_CONTENT, 'label' => esc_html__( 'Content', 'metform' ), ] ); $this->quiz_controls(['multi-select']); } else { $this->start_controls_section( 'content_section', [ 'label' => esc_html__( 'Content', 'metform' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->input_content_controls(); $input_fields = new Repeater(); $input_fields->add_control( 'label', [ 'label' => esc_html__( 'Input Field Text', 'metform' ), 'type' => Controls_Manager::TEXT, 'default' => esc_html__( 'Input Text' , 'metform' ), 'label_block' => true, 'description' => esc_html__('Select list text that will be show to user.', 'metform'), ] ); $input_fields->add_control( 'value', [ 'label' => esc_html__( 'Input Field Value', 'metform' ), 'type' => Controls_Manager::TEXT, 'default' => esc_html__( 'Input Value' , 'metform' ), 'label_block' => true, 'description' => esc_html__('Select list value that will be store/mail to desired person.', 'metform'), ] ); $input_fields->add_control( 'mf_input_option_status', [ 'label' => esc_html__( 'Status', 'metform' ), 'type' => Controls_Manager::SELECT, 'default' => '', 'options' => [ '' => esc_html__( 'Enable', 'metform' ), 'disabled' => esc_html__( 'Disable', 'metform' ), ], 'description' => esc_html__('Want to make a option? which user can see the option but can\'t select it. make it disable.', 'metform'), ] ); $input_fields->add_control( 'mf_input_option_selected', [ 'label' => esc_html__( 'Select it default ? ', 'metform' ), 'type' => Controls_Manager::SELECT, 'default' => '', 'options' => [ 'selected' => esc_html__( 'Yes', 'metform' ), '' => esc_html__( 'No', 'metform' ), ], 'description' => esc_html__('Make this option default selected', 'metform'), ] ); $this->add_control( 'mf_input_list', [ 'label' => esc_html__( 'Multi Select List', 'metform' ), 'type' => Controls_Manager::REPEATER, 'fields' => $input_fields->get_controls(), 'title_field' => '{{{ label }}}', 'default' => [ [ 'label' => 'Item 1', 'value' => 'value-1', 'mf_input_option_status' => '', ], [ 'label' => 'Item 2', 'value' => 'value-2', 'mf_input_option_status' => '', ], [ 'label' => 'Item 3', 'value' => 'value-3', 'mf_input_option_status' => '', ], ], 'description' => esc_html__('You can add/edit here your selector options.', 'metform'), 'frontend_available' => true, ] ); } $this->end_controls_section(); $this->start_controls_section( 'settings_section', [ 'label' => esc_html__( 'Settings', 'metform' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->input_setting_controls(); $this->add_control( 'mf_input_validation_type', [ 'label' => __( 'Validation Type', 'metform' ), 'type' => \Elementor\Controls_Manager::HIDDEN, 'default' => 'none', ] ); $this->input_get_params_controls(); $this->end_controls_section(); if(class_exists('\MetForm_Pro\Base\Package')){ $this->input_conditional_control(); } if ( $this->get_form_type() == 'quiz-form' && class_exists('\MetForm_Pro\Base\Package') ) { $this->start_controls_section( 'label_section', [ 'label' => esc_html__( 'Label', 'metform' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); } else { $this->start_controls_section( 'label_section', [ 'label' => esc_html__( 'Label', 'metform' ), 'tab' => Controls_Manager::TAB_STYLE, 'conditions' => [ 'relation' => 'or', 'terms' => [ [ 'name' => 'mf_input_label_status', 'operator' => '===', 'value' => 'yes', ], [ 'name' => 'mf_input_required', 'operator' => '===', 'value' => 'yes', ], ], ], ] ); } $this->input_label_controls(); $this->end_controls_section(); $this->start_controls_section( 'input_section', [ 'label' => esc_html__( 'Input', 'metform' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->input_controls(); $this->end_controls_section(); $this->start_controls_section( 'placeholder_section', [ 'label' => esc_html__( 'Place Holder', 'metform' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->input_place_holder_controls(); $this->end_controls_section(); $this->start_controls_section( 'help_text_section', [ 'label' => esc_html__( 'Help Text', 'metform' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'mf_input_help_text!' => '' ] ] ); $this->input_help_text_controls(); $this->end_controls_section(); $this->insert_pro_message(); } protected function render($instance = []){ $settings = $this->get_settings_for_display(); $inputWrapStart = $inputWrapEnd = ''; extract($settings); $render_on_editor = true; $is_edit_mode = 'metform-form' === get_post_type() && \Elementor\Plugin::$instance->editor->is_edit_mode(); /** * Loads the below markup on 'Editor' view, only when 'metform-form' post type */ if ( $is_edit_mode ): $inputWrapStart = '
'; endif; $class = (isset($settings['mf_conditional_logic_form_list']) ? 'mf-conditional-input' : ''); $configData = [ 'message' => $errorMessage = isset($mf_input_validation_warning_message) ? !empty($mf_input_validation_warning_message) ? $mf_input_validation_warning_message : esc_html__('This field is required.', 'metform') : esc_html__('This field is required.', 'metform'), 'minLength' => isset($mf_input_min_length) ? $mf_input_min_length : 1, 'maxLength' => isset($mf_input_max_length) ? $mf_input_max_length : '', 'type' => isset($mf_input_validation_type) ? $mf_input_validation_type : '', 'required' => isset($mf_input_required) && $mf_input_required == 'yes' ? true : false, ]; $mf_default_input_list = isset($mf_input_list) ? array_values(array_filter($mf_input_list, function($item){ if(isset($item['mf_input_option_selected']) && !empty($item['mf_input_option_selected'])){ return $item["value"]; } return false; })) : array(); $default_value = count($mf_default_input_list) > 0 ? array_column($mf_default_input_list, 'value') : array(); if(!$is_edit_mode && isset($mf_quiz_point) && class_exists('\MetForm_Pro\Base\Package')){ $answer_list = isset($mf_input_list) ? array_values(array_filter($mf_input_list, function($item){ if(isset($item['mf_quiz_question_answer']) && !empty($item['mf_quiz_question_answer'])){ return $item["value"]; } return false; })) : array(); $answers = count($answer_list) > 0 ? array_column($answer_list, 'value') : array(); $quizData = array("answer" => $answers, "correctPoint" => esc_attr($mf_quiz_point ?? 0), "incorrectPoint" => esc_attr($mf_quiz_negative_point ?? 0)); } ?>
<${props.Select} isOptionDisabled=${option => option.mf_input_option_status === 'disabled'} className=${"mf-input mf-input-multiselect " + ( validation.errors[''] ? 'mf-invalid' : '' )} classNamePrefix="mf_multiselect" value=${parent.getValue("") && .filter(item => { if(parent.state.formData[''] && parent.state.formData[''].indexOf(item.value) != -1 ){ return item; } })} name='' placeholder="" options=${} onChange=${(el) => { setValue("", ''); if(el != null){ setValue("", el, true); } parent.multiSelectChange(el, ''); }} ref=${() => { !parent.state.answers[""] && ( parent.state.answers[""] = ) register({ name: "" }, parent.activateValidation()); if(parent.state?.submitted !== true){ if ( parent.getValue("") === '' && 0) ? 'true' : 'false'; ?> ) { parent.setValue( '', ''); parent.multiSelectChange('', ''); } } }} isMulti /> <${validation.ErrorMessage} errors=${validation.errors} name="" as=${html``} /> %s ', esc_html( \MetForm\Utils\Util::react_entity_support(trim($mf_input_help_text), $render_on_editor))) : ''); ?>