Flash message and Turbo Router Bug

hi
I have a problem with the redirect not showing up Flash message

My code:

function onSubmit()
{
    	 $messages = [
		'required' => 'This field is required',
		'value1.numeric' => 'This field accepts numbers only',


	];
	$validator = Validator::make(
				$form = Input::all(), [
				   'value1' => 'required|numeric',


				],$messages
			);

			if ($validator->fails()) {
				throw new ValidationException($validator);
			}
            
    Flash::success(Input::get('value1'));
    return Redirect::refresh();
  
  
}

My flash message code:

{% flash %}
	<div  data-control="flash-message" data-interval="5" class="oc-flash-message {{ type }} flash-show" >
		<span> {{ message }}</span>
		<a class="flash-close"></a>
	</div>
{% endflash %}

i include this code in my layouts page

 <meta name="turbo-visit-control" content="reload" />
    	{% framework %}
	{% framework extras turbo %}

my Form code:

<form 
      data-request="onSubmit" 
      data-request-flash 
     >

  <div class="form-row">
      <!-- input start -->
        <div class="form-group col-md-4">
          <input type="text" class="form-control"   name="value1" >
        </div>

        <div class="form-group col-md-4">
            <button  data-attach-loading class="btn btn-outline-primary" type="submit">do</button>
        </div>
    </div>

</form>

When i use return Redirect::refresh(); or Redirect::back(); the success message do not show but error message showing up normal but does not disappear automatically!!!
and
if i disable Turbo Router and include “{% framework extras %}” only the flash message show in info panel "blue panel " above success panel "green panel " meaning it launch 2 flash message one success and other info at the same time !!
-Note: include “{% framework extras turbo %}” show one panel (info panel "blue panel ") even if i use success message

  • MY BUILD Version is 3.1.23
    Thanks…

You may need to remove this line since it forces a reload and will lose the flash messages. Alternatively, you can remove turbo from the framework tag.

thank you for reply
Everything I talk about is happening in frontEnd
I already removed everything
So the bug in flash message is the type of message , “info” replace “success” message
and
the error massage stuck in frontEnd do not disappear

You can try it

<p>
    <a href="#" class="btn btn-primary" onclick="$.oc.flashMsg({ message: 'success!', type: 'success' }); return false;">
        Show Success
    </a>

    <a href="javascript:;" class="btn btn-danger" onclick="$.oc.flashMsg({ message: 'error!', type: 'error'}); return false;">
        Show Error
    </a>
    <a href="javascript:;" class="btn btn-info" onclick="$.oc.flashMsg({ message: 'info!', type: 'info'}); return false;">
        Show info
    </a>
    <a href="javascript:;" class="btn btn-warning" onclick="$.oc.flashMsg({ message: 'Warning! ', type: 'warning'}); return false;">
        Show Warning
    </a>
</p>

-i update octobercms to Version is 3.1.24

the error massage stuck in frontEnd

<p>
    <a href="javascript:;" class="btn btn-danger" onclick="$.oc.flashMsg({ message: 'error!', type: 'error'}); return false;">
        Show Error
    </a>
</p>

@daftspunky

This is probably cause:

modules/system/assets/js/framework-bundle.js:309

  if (type !== 'error') {
    timer = window.setTimeout(remove, interval * 1000);
  } // Remove logic

So only not error messages dissapear after interval. This only happens when you use this syntax: $.oc.flashMsg({ message: 'error!', type: 'error'});

Setting “interval” in this call will not work as well.

Hi @Renatio

Yes, this is part of the design. Since errors usually contain valuable information about what went wrong, they do not disappear automatically.