Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- title = "user"
- url = "/user"
- layout = "default"
- is_hidden = 0
- robot_index = "index"
- robot_follow = "follow"
- [session]
- security = "all"
- [account]
- paramCode = "code"
- forceSecure = 0
- requirePassword = 0
- ==
- <?php
- use RainLab\User\Models\User as UserModel;
- function onSave()
- {
- $data = post();
- $rules = [
- 'name' => 'required',
- 'email' => 'required|email',
- 'password' => 'confirmed|min:8',
- ];
- $validation = Validator::make($data, $rules);
- if ($validation->fails()) {
- throw new ValidationException($validation);
- }
- $id = input('id');
- $user = UserModel::where('id', $id)->first();
- $user->fill($data);
- $notescount = input('notescount');
- // dd($notescount);
- $notes = [];
- for ($i = 1; $i <= $notescount; $i++) {
- if(input('note' . $i)){
- $notes[] = ['notes' => input('note' . $i) ];
- }
- }
- $user->setField('myfields', $notes);
- $user->save();
- Flash::success('Successfully saved!');
- if (array_key_exists('password', $data) && strlen($data['password'])) {
- Auth::login($user->reload(), true);
- }
- }
- ?>
- ==
- <section id="demo" class="section demos bg-gray">
- <div class="container">
- <div class="row">
- <div class="col-sm-12 text-center section-title">
- <br>
- {% if not user %}
- {% component 'account' %}
- {% endif %}
- {% if user %}
- <div id="customfields">
- {% partial 'user' %}
- </div>
- <p>Hello {{ user.name }}</p>
- <a data-request="onLogout" data-request-data="redirect: '/user'">Sign out</a>
- {% else %}
- <p>Nobody is logged in</p>
- {% endif %}
- </div>
- </div>
- </div>
- </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement