Commit 7f2a216e authored by Denis S. Valdenaire's avatar Denis S. Valdenaire

validation sur payment_method

parent 2b57e0e9
......@@ -34,5 +34,21 @@ class Payment_Method extends Record {
// if the payment method is used somewhere, that
// can't be done
// so overload the record method
}
public function validate_input(&$errors) {
$v = new Valitron\Validator($_REQUEST);
$v->rule('required', ['name', 'description']);
$v->labels(array(
'name' => 'Le nom',
'description' => 'La description'
));
if($v->validate()) {
$errors = null;
return true;
} else {
// Errors
$errors = $v->errors();
return false;
}
}
}
{% extends 'modal.html' %}
{% extends 'modal_api.html' %}
{% block modal_title %}
{% if object.id %} Méthode de paiement : {{ object.name }} {% else %} Nouvelle méthode de paiement {% endif %}
{% endblock %}
{% block modal_body %}
<div class="alert alert-info alert-dismissible" role="alert" style="display: none" id="created_ok">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<span class="glyphicon glyphicon-ok"></span>
Création effectuée
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="name">Nom</label>
<div class="col-sm-10">
<input type="text" id="name" name="name" class="form-control" value="{{ object.name }}"/>
<span id="help-name" class="help-block" style="display: none"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="description">Description</label>
<div class="col-sm-10">
<textarea id="description" name="description" class="form-control" rows="4">{{ object.description }}</textarea>
<span id="help-description" class="help-block" style="display: none"></span>
</div>
</div>
{% endblock %}
{% block javascript_fields %}
var fields = ['name', 'description'];
{% endblock %}
{% block javascript_msg %}
var msg = 'Voulez-vous réellement supprimer cette méthode de paiement ?\n' +
'Cette action n\'est possible que si cette méthode n\'a pas été\n' +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment