private function cleanForm($requestData, Form $form)
    {
        $allowedField = array_keys($requestData);

        /** @var FormInterface[] $formFields */
        $formFields = $form->all();
        foreach ($formFields as $formField) {
            $fieldName = $formField->getName();

            if (!in_array($fieldName, $allowedField)) {
                $form->remove($fieldName);
            }
        }
    }
private function cleanForm($requestData, Form $form)
    {
        $allowedField = array_keys($requestData);

        /** @var FormInterface[] $formFields */
        $formFields = $form->all();
        foreach ($formFields as $formField) {
            $fieldName = $formField->getName();

            if (!in_array($fieldName, $allowedField)) {
                $form->remove($fieldName);
            }
        }
    }
private function cleanForm ( $ requestData , Form $ form ) { $ allowedField = array_keys ( $ requestData ) ; /** @var FormInterface[] $formFields */ $ formFields = $ form -> all ( ) ; foreach ( $ formFields as $ formField ) { $ fieldName = $ formField -> getName ( ) ; if ( ! in_array ( $ fieldName , $ allowedField ) ) { $ form -> remove ( $ fieldName ) ; } } }
Remove unnecessary fields from form

@param array $requestData
@param Form $form
Remove unnecessary fields from form