i'm trying to figure out how to get the data out of the serialized string of the submitted form.
$(document).ready(function() {
    $("#formC").on('submit', function(e) {
         var url = $(this).attr("action");
        e.preventDefault();
        $.post(url,{
            data: $("#formC").serialize(),
            type: 'post'
        }).done(function(data) {
            alert(data);
        });
    });
Form:
<form action="{{ path('advd_p_group_ps_rd_ss') }}" method="post" {{ form_enctype(formBase) }} id="formC">
                                    <thead>
                                        <tr>
                                            <th><input type="checkbox" id="selectall"></th>
                                            <th>{{ 'general.date'|trans }}</th>
                                            <th>{{ 'general.order_number'|trans }}</th>
                                            <th>{{ 'general.description'|trans }}</th>
                                            <th>{{ 'general.company_name'|trans }}</th>
                                            <th>{{ 'general.name'|trans }}</th>
                                            <th>{{ 'form.status'|trans }}</th>
                                        </tr>
                                    </thead>
                                        {% for details in details %}
                                    <tbody>
                                        <tr>
                                            <td><div align="center"><input type="checkbox" class="selectedId" name="selectedId" value="{{details.id}}" onclick="javascript:resetSelectAll();" /></div></td>
                                            <td>{{ details.date | date("m/d/Y") }}</td>
                                            <td>{{ details.order_number }}</td>
                                            <td>{{ details.description }}</td>
                                            <td>{{ details.company }}</td>
                                            <td>{{ details.name }}</td>
                                            <td>{{ details.status }}</td>
                                        </tr>
                                    </tbody>
                                        {% endfor %}
                            </table> 
                        </div>
                    </div>
                {% if info == 1 %}
                    <div id="information">
                        <div id="tableContent">
                                    {{ form_widget(form) }}
                            <input class="input_button" type="submit" value="Procesar" id="procesar" />
                            </form>
Controller:
public function groupBatchPrizesRequestedAction(Request $request){
   if ( $request->getMethod() == 'POST' ) {
        $data = $request->get('data');
}
The output when I do die($data) is something like this:
selectedId=23&selectedId=25&requested%5Bstatus%5D=11&requested%5Bcomments%5D=sdsds&requested%5B_token%5D=e40bc826cce8b756ecce002181301e951e588028
My question is, how do I get all "selectedId", requested_status and comments from it? Is there a way to send it as an array, an array it's easier to handle...
Use serializeArray function to correctly submit your data.
$.post(url,{
    data: $("#formC").serializeArray(),
    type: 'post'
})
                        Use in your controller:
$request = $this->get('request');
$data = $request->request->all();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With