Phoenix Form
PhoenixForm is a HTML form operation helper, include it by:
\Phoenix\Script\PhoenixScript::form('#my-form');
And you must have a <form id="#admin-form"> ...
element in your HTML so Phoenix can operate this form.
Submit and RESTful CRUD
You can simply use this JS code to submit form:
// Submit with default action defined on <form action="...">
Phoenix.submit();
// Submit with custom URI and query
Phoenix.submit('/flower/sakuras', {page: 3});
// Send POST
Phoenix.submit('/flower/sakura', data, 'POST');
// Send custom RESTful method, will add `_method` to your params
Phoenix.submit('/flower/sakura', data, 'POST', 'PUT');
In PHP template, it wil look like:
Phoenix.submit('{{ $router->route('sakura') }}', {page: 3});
Use simple methods:
// GET
Phoenix.get('/flower/sakura/25', query);
// POST
Phoenix.post('/flower/sakura/25', query);
// POST with custom method
Phoenix.post('/flower/sakura/25', query, 'PUT');
// PUT
Phoenix.put('/flower/sakura/25', query);
// PATCH
Phoenix.patch('/flower/sakura/25', query);
// DELETE
Phoenix.sendDelete('/flower/sakura/25', query);
On click event in HTML element:
<button type="button" onclick="Phoenix.post()"></button>
If you found a typo or error, please help us improve this document.