makeElementId($data, $form); $isMulti = ArrayHelper::get($data, 'settings.enable_select_2') == 'yes'; if (ArrayHelper::get($data['attributes'], 'multiple')) { $data['attributes']['name'] = $data['attributes']['name'].'[]'; wp_enqueue_script('choices'); wp_enqueue_style('ff_choices'); $data['attributes']['class'] .= ' ff_has_multi_select'; } else if($isMulti) { wp_enqueue_script('choices'); wp_enqueue_style('ff_choices'); $data['attributes']['class'] .= ' ff_has_multi_select'; } $data['attributes']['data-calc_value'] = 0; if(!isset($data['attributes']['class'])) { $data['attributes']['class'] = ''; } $data['attributes']['class'] = trim('ff-el-form-control ' . $data['attributes']['class']); if($tabIndex = \FluentForm\App\Helpers\Helper::getNextTabIndex()) { $data['attributes']['tabindex'] = $tabIndex; } $defaultValues = (array) $this->extractValueFromAttributes($data); if($dynamicValues = $this->extractDynamicValues($data, $form)) { $defaultValues = $dynamicValues; } $elMarkup = ""; $html = $this->buildElementMarkup($elMarkup, $data, $form); echo apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form); } /** * Build options for select * @param array $options * @return string/html [compiled options] */ protected function buildOptions($data, $defaultValues) { if(!$formattedOptions = ArrayHelper::get($data, 'settings.advanced_options')) { $options = ArrayHelper::get($data, 'options', []); $formattedOptions = []; foreach($options as $value => $label) { $formattedOptions[] = [ 'label' => $label, 'value' => $value, 'calc_value' => '' ]; } } $opts = ''; if (!empty($data['settings']['placeholder'])) { $opts .= ''; } else if(!empty($data['attributes']['placeholder'])) { $opts .= ''; } foreach ($formattedOptions as $option) { if(in_array($option['value'], $defaultValues)) { $selected = 'selected'; } else { $selected = ''; } $atts = [ 'data-calc_value' => ArrayHelper::get($option, 'calc_value'), 'data-custom-properties' => ArrayHelper::get($option, 'calc_value'), 'value' => ArrayHelper::get($option, 'value'), ]; $opts .=""; } return $opts; } }