| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Modules\Form; |
| 4 |
|
| 5 |
use FluentForm\App\Modules\Acl\Acl; |
| 6 |
use FluentForm\App\Services\FormParser; |
| 7 |
use FluentForm\Framework\Foundation\Application; |
| 8 |
|
| 9 |
class Inputs |
| 10 |
{ |
| 11 |
/** |
| 12 |
* @var \FluentForm\Framework\Request\Request |
| 13 |
*/ |
| 14 |
private $request; |
| 15 |
|
| 16 |
/** |
| 17 |
* Build the class instance |
| 18 |
* @throws \Exception |
| 19 |
*/ |
| 20 |
public function __construct(Application $application) |
| 21 |
{ |
| 22 |
Acl::verify('fluentform_forms_manager'); |
| 23 |
|
| 24 |
$this->request = $application->request; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Get all the flatten form inputs |
| 29 |
* @return void |
| 30 |
*/ |
| 31 |
public function index() |
| 32 |
{ |
| 33 |
$formId = $this->request->get('formId'); |
| 34 |
|
| 35 |
$form = wpFluent()->table('fluentform_forms')->find($formId); |
| 36 |
$fields = (new FormParser($form))->getEntryInputs(array('admin_label', 'attributes', 'options')); |
| 37 |
wp_send_json($fields, 200); |
| 38 |
} |
| 39 |
} |