| @@ -1,17 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentForm\App\Modules\Form; |
| 4 | 4 | |
| 5 | -use FluentForm\App; | |
| 6 | -use FluentForm\App\Modules\Acl\Acl; | |
| 5 | +use FluentForm\App\Services\Form\Fields; | |
| 7 | 6 | use FluentForm\Framework\Foundation\Application; |
| 8 | -use FluentForm\App\Services\FormBuilder\EditorShortcode; | |
| 9 | -use FluentForm\Framework\Helpers\ArrayHelper; | |
| 10 | 7 | |
| 11 | 8 | class Inputs |
| 12 | 9 | { |
| 13 | 10 | /** |
| 11 | + * Request object | |
| 12 | + * | |
| 14 | 13 | * @var \FluentForm\Framework\Request\Request |
| 15 | 14 | */ |
| 16 | 15 | private $request; |
| 17 | 16 | |
| @@ -16,8 +15,9 @@ | ||
| 16 | 15 | private $request; |
| 17 | 16 | |
| 18 | 17 | /** |
| 19 | 18 | * Build the class instance |
| 19 | + * | |
| 20 | 20 | * @throws \Exception |
| 21 | 21 | */ |
| 22 | 22 | public function __construct(Application $application) |
| 23 | 23 | { |
| @@ -30,60 +30,7 @@ | ||
| 30 | 30 | public function index() |
| 31 | 31 | { |
| 32 | 32 | $formId = $this->request->get('formId'); |
| 33 | 33 | |
| 34 | - $form = wpFluent()->table('fluentform_forms')->find($formId); | |
| 35 | - | |
| 36 | - $fields = FormFieldsParser::getShortCodeInputs($form, [ | |
| 37 | - 'admin_label', 'attributes', 'options' | |
| 38 | - ]); | |
| 39 | - | |
| 40 | - $fields = array_filter($fields, function ($field) { | |
| 41 | - return in_array($field['element'], $this->supportedConditionalFields()); | |
| 42 | - }); | |
| 43 | - | |
| 44 | - wp_send_json($this->filterEditorFields($fields), 200); | |
| 45 | - } | |
| 46 | - | |
| 47 | - public function supportedConditionalFields() | |
| 48 | - { | |
| 49 | - $supportedConditionalFields = [ | |
| 50 | - 'select', | |
| 51 | - 'ratings', | |
| 52 | - 'net_promoter', | |
| 53 | - 'textarea', | |
| 54 | - 'shortcode', | |
| 55 | - 'input_url', | |
| 56 | - 'input_text', | |
| 57 | - 'input_date', | |
| 58 | - 'input_email', | |
| 59 | - 'input_radio', | |
| 60 | - 'input_number', | |
| 61 | - 'select_country', | |
| 62 | - 'input_checkbox', | |
| 63 | - 'input_password', | |
| 64 | - 'terms_and_condition', | |
| 65 | - 'gdpr_agreement', | |
| 66 | - 'input_hidden', | |
| 67 | - 'input_file', | |
| 68 | - 'input_image' | |
| 69 | - ]; | |
| 70 | - | |
| 71 | - return apply_filters('fluentform_supported_conditional_fields', $supportedConditionalFields); | |
| 72 | - } | |
| 73 | - | |
| 74 | - public function filterEditorFields($fields) | |
| 75 | - { | |
| 76 | - foreach ($fields as $index => $field) { | |
| 77 | - $element = ArrayHelper::get($field, 'element'); | |
| 78 | - if($element == 'select_country') { | |
| 79 | - $fields[$index]['options'] = App::load( | |
| 80 | - App::appPath('Services/FormBuilder/CountryNames.php') | |
| 81 | - ); | |
| 82 | - } else if($element == 'gdpr-agreement' || $element == 'terms_and_condition') { | |
| 83 | - $fields[$index]['options'] = array('on' => 'Checked'); | |
| 84 | - } | |
| 85 | - } | |
| 86 | - | |
| 87 | - return $fields; | |
| 34 | + wp_send_json((new Fields())->get($formId), 200); | |
| 88 | 35 | } |
| 89 | 36 | } |