javascript - Can I create a Symfony form submission, entirely in the controller? -
I have a symphonic formatting in which the event listener, including some event posters, has an image to upload an image.
I have additional functionality instead of uploading an image from the browser, users can choose from the photos that drown
is the flow, click to launch the "selector", choose photo Upload a response to my controller from Dropbox via AJAX. My Symphony Controller receives one of these Array requests:
"Bytes": "7466873", "icon": "https://www.dropbox.com/static/images / Icons64/page_white_picture.png "," link ":" https://api-content.dropbox.com/1/some-image/IMG_8956.JPG "," name ":" IMG_8956.JPG "," thumbnailLink ": "Https: //api-content.dropbox.com/1/some-image"
What I want to do in my controller, it changes in general $ form -> gt; HandleRequest ($ request);
So I can use the same form, same verification, poststream work on it.
Is it possible to completely copy a "form" to an administrator?
public function dbUploadAction (request $ request) {// Check that this is an Ajax request if (! $ Request-> is XmlHttpRequest ()) {throw $ this-> CreateNotFoundException ();} $ files = $ Request-> Get ('file'); // To submit an example to a form I submit $ document = new document (); $ Form = $ this- & gt; CreateForm ('document', $ document); Do something with // $ files here $ form-> Submit (my $ files); If ($ form-> isValid ()) {// do some actions ... // continue as if the user submits the form to the browser) $ r = $ this- & gt; Container-> Receive ('Serializer') - & gt; Serial ($ files, 'jason'); Return new responses ($ r); } I think that I have done something like this while running some unit tests. I was sending the controller through some controller through a controller and it was behaving like a form submission: // change the array $ data = json_decode to a JSON Do ($ request-> getContent (), true); // Start new document $ document = new document (); // blank document form $ form = $ this- & gt; CreateForm (create new DocumentType (), $ document; // Generate the form of the form (document field), it is $ form-> To fill the dam ($ data); // Now validate the form if ($ form-> isValid ()) {// business in general}
Comments
Post a Comment