lundi 27 mars 2017

Access value before it's converted by an attribute accessor

I have an accessor on my model for a boolean column:

public function getActiveAttribute($value)
    {
        if ($value == 0) {
            return "No";
        } else {
            return "Yes";
        }
    }

The problem I am having is the corresponding form input, a radio button, does not have either options selected when I go to a create or edit view. I could amend the form so the values of the radio buttons are "Yes" and "No" and then write a mutator for the same field.

Is there a better way to do it?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ntQSXx
via IFTTT

Aucun commentaire:

Enregistrer un commentaire