M
M
Messi2017-09-04 20:06:02
css
Messi, 2017-09-04 20:06:02

How to display your error correctly?

The form has a TinyMCE widget with the image upload capability. When pictures are loaded, everything is OK, but when I purposefully load a file of a different format instead of a picture, I get an alert (http error 500). This code is written in tinymce .js in defaultHandler

xhr.onload = function () {
          var json;

          if (xhr.status < 200 || xhr.status >= 300) {
<b>            failure("HTTP Error: " + xhr.status);</b>
            return;
          }

Question: how to overwrite or intercept this code (using js or php) and display your error instead of the standard one?
Connection code :
<?= $form->field($model, 'content')->widget(TinyMce::className(), [
            'options' => ['rows' => 6],
            'clientOptions' => [
                'plugins' => [
                    "advlist autolink lists link charmap print preview anchor",
                    "searchreplace visualblocks code fullscreen",
                    "insertdatetime media table contextmenu paste",
                    "image imagetools",
                ],
                'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
                'min_height' => 300,
                'images_upload_url' => 'tiny-photo',
            ]
        ]);?>

tiny-photo - an action that saves a photo and simply returns json {'location' : '/img/name12.jpg'} for a TinyMCE script

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Kotov, 2019-05-16
_

to make a parallelogram shape use transform: skew(20deg);
for a white background from the top, use linear-garient where the second color is transparent. I'm sitting on the phone, I can't throw off the sandbox

F
Fetur, 2017-09-04
@Fetur

If it's a 500 error, then it's a backend.
There, use ini_set('display_errors', 1); //Possible typo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question