jeudi 16 janvier 2020

Properly validate if a WYSIWYG field is not an empty or break-line only in Laravel

I'm trying to validate if a WYSIWYG contains only line breaks and empty spaces and returns a required error if it falls on this one. I have a controller file and my created request file too. In my controller, I'm calling the created request I have.

public function update(myRequest $request){
    //some code
}

//myRequest file
public function rules() {
    // remove nbsp and all html tags
    if(strlen(str_replace(" ", '', strip_tags(\Request()->remarks))) == 0){
        \Request()->remarks = null;
        // it gets in on this condition
    }
    dd(\Request::all());
}

My problem now is that the remarks value is not changed into null thus my is not working as expected since it has still the htmls tags and  . How can I properly set the value of remarks to null if it contains only   and html tags ?



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

Aucun commentaire:

Enregistrer un commentaire