This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

orvil
orvil

Hi all, I tried the example given in https://octobercms.com/docs/ajax/extras#usage-example

Created a new partial named 'testAjax' for this, copied the HTML for the markup section into the markup section of this partial ...

    <form

      data-request="onDoSomething"

      data-request-validate

      data-request-flash>

        <div>

            <input name="name" />

            <span data-validate-for="name"></span>

        </div>

       ...

    </form>

... and the php code for the code section into the code section of the same partial:

    function onDoSomething()   {

            $data = post();

            $rules = [

                'name' => 'required',

                'email' => 'required|email',

            ];

        $validation = Validator::make($data, $rules);

        if ($validation->fails()) {

            throw new ValidationException($validation);

        }

         Flash::success('Jobs done!');

    }

Anyhow this does not work - except I copy the code into the page code section! Is there any way to make this code working within the code section of the partial?

Thanks in advance for your suggestions!

Last updated

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.