Skip to content

Instantly share code, notes, and snippets.

View Bisb's full-sized avatar

Guillaume Adam Bisb

  • Strasbourg, France
View GitHub Profile
@Bisb
Bisb / load_dotenv.sh
Created July 3, 2024 18:45 — forked from HT2Knock/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
if [ -f .env ]
then
export $(grep -v '^#' .env | xargs)
fi
@Bisb
Bisb / FormErrorsSerializer.php
Last active October 20, 2016 18:43 — forked from Graceas/FormErrorsSerializer.php
Symfony 2 Form Error Serializer. May be used for AJAX form validation. Allows tree and flat array styles for errors.
<?php
class FormErrorsSerializer {
public function serializeFormErrors(\Symfony\Component\Form\Form $form, $flat_array = false, $add_form_name = false, $glue_keys = '_')
{
$errors = array();
$errors['global'] = array();
$errors['fields'] = array();
foreach ($form->getErrors() as $error) {
@Bisb
Bisb / form.js
Last active October 20, 2016 18:45 — forked from Graceas/form.js
Symfony 2 used FormErrorsSerializer.php with jQuery.
// HTML form part
// < form class="form" action="{{ path('...') }}" method="POST" onsubmit="form_callback(this); return false;" >
function form_callback(target)
{
target = $(target);
$.ajax({
url: target.attr('action'),
type: target.attr('method'),
data: target.serialize(),