yoanbernabeu / Airtable-Client-Bundle

Simple Client for Airtable API
MIT License
33 stars 12 forks source link

Easy form creation #23

Closed yoanbernabeu closed 3 years ago

yoanbernabeu commented 3 years ago

I propose to add the possibility of using the Form Component of Symfony to facilitate the creation of an Airtable recording.

An example of use within a Symfony application:

     /**
     * @Route("/add", name="add")
     */
    public function add(AirtableClientInterface $airtableClient, Request $request): Response
    {
        $form = $airtableClient->createForm([
            'Name' => TextType::class,
            'text' => TextType::class,
            'Submit' => SubmitType::class
        ]);

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $task = $form->getData();
            $airtableClient->add('test', $task);
            return $this->redirectToRoute('home');
        }

        return $this->render('test.html.twig', [
            'form' => $form->createView()
        ]);
    }