Usage

Forms with Limpid
Sending forms with limpid never been easy, in few simple steps:
  • Prepare your form
  • Create your route and command
  • And call the magic function inside your controller $this->getHttpHandler()->get(the method you used in the form)
Our route
<?php

return [
'myview_route' => [ //--your route's name
'pattern' => '/my-view', //--the pattern that will be displayed in the url input of the browser
'command' => 'HelloLimpid_Default:myview', //---and the command that will be executed
],
'form_route' => [ 'pattern' => '/myform', 'command' => 'HelloLimpid_Default:sendForm', ], ]
Our view
    <!--In your file app.html.twig-->
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>{% block page_title %}{% endblock %}</title>
    </head>
    <body>
     <form action="{{ route('form_route') }}" method="POST">
        <label for="title">Title</label><input type="text" name="title" id="title" />
        <label for="designation"><textarea name="designation" id="designation"></textarea>
     </form>
    </body>
    </html>
OK, wait a second ! What is this  {{ route('form_route') }} ?!!
Oh you noticed :p
This is a Twig extension provided by Limpid that gets the route by it's name and convert it into an url.
Now let's get our submitted data
    
    /*Inside the controller*/
    public function sendFormCommand(){
        $data = $this->getHttpHandler()->get(HTTPHandler::POST);//--get form data with the POST method
        echo 'Title: '.$data['title'].'<br>Designation: '.$data['designation'];//--display sent inputs by their names
    }

Ok this looks great and how to get input with type="file" ?
Well this is a good question, Limpid's HTTPHandler class handle the data with type="file" and return it as an object with type 
FileField which means that there is 
no need to do such stuff:
 
 $file = $_FILE['input_name']['name']
 $tmp = $_FILE['input_name']['tmp_name']
 move_uploaded_file('path\to\directory', $tmp);

Ugh, this is bad isn't ?
well this is the functions provided by 
FileField
 
 $data = $this->getHttpHandler()->get(HTTPHandler::POST);
 $file = $data['input_name'];//--you have a FileField object
 $file->fileName();//--get file's name
 $file->hasData();//--check if file is sent and contains data
 $file->save('path\to\directory');//--save the file
 /**
  * ...
  * and much more
  * Take your time to discover it :)
  */