Hi guys
I am just starting my Ci journey, and am following a tutorial from Udemy. Basic app is allow users to register and then create a blog article.
As extra "homework" I am adding functionality to edit a users name and email address. I have everything working but am hitting an issue with an include file and am after some guidance - I am sure I am missing something obvious here..
So, I have an Admin module, laid out thus:
Code:
Admin
-> Config
-> Database
-> Helpers
-> View
->->Users
->->->Edit.php
->->->form.php
->->->index.php
->->->show.php
app
->Config
etc...
The issue is is with the Edit, the code for which is:
Code:
<?= $this->extend('Layouts\default') ?>
<?= $this->section("title") ?>Edit User<?= $this->endSection() ?>
<?= $this->section("content") ?>
<h1>Edit User</h1>
<?php if (session()->has("errors")): ?>
<ul>
<?php foreach(session("errors") as $error): ?>
<li><?= $error ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?= form_open("admin/users/" . $user->id) ?>
<input type="hidden" name="_method" value="PATCH">
<?= $this->include("Admin\Views\Users\\form") ?>
<!-- <label for="title">Email:</label>
<input type="text" id="email" name="email" value="<?= old("title", esc($user->email)) ?>">
<label for="content">First Name:</label>
<input type="text" id="first_name" name="first_name" value="<?= old("title", esc($user->first_name)) ?>"> -->
<button>Save</button>
</form>
<?= $this->endSection() ?>
The issue is the line:
Code:
<?= $this->include("Admin\Views\Users\\form") ?>
As you can see, I have had to escape the name of the file in order to get it to be picked up - but this doesn't feel right to me.
I have played with adding APPPATH and ROOTPATH to the include path, but these don't work either.
The error I get "Invalid file" and I have tried various combinations of the Admin\Views\Users, with backslashes, forward slashes - all with the same error.
The code in the form.php file is in the code above, just commented out. If I uncomment it and comment out the include call, it all works.
Please help a newbie!
Thanks
Darren