Is this a terrible idea? Is there a better way to accomplish this?
One thing that makes a great designer/developer is knowing when to say no. It could be done but it's probably not worth it. If you need to ask the question, sometimes you just need to validate your own thoughts.
At the expense of not answering your other questions, I'd say Freeform is great for non-technical, end users who need to create custom forms that may need to change on a whim at some point.
However, I'm just curious as to why you're trying to use it to "reinvent the wheel" for the login/registration fields when Craft itself already has the proper validation and access control checking built in for those?
The great thing about Craft is the CSS is up to you, so I'm not really sure what you're really gaining by doing this?
If you're trying to get the styling to look right, something like Bootstrap, Foundation or Tailwind might be useful.
Your login form is just 2 fields, user and password:
<form method="post" accept-charset="UTF-8">
{{ csrfInput() }}
{{ actionInput('users/login') }}
<h3><label for="loginName">Username or email</label></h3>
<input id="loginName" type="text" name="loginName"
value="{{ craft.app.user.rememberedUsername }}">
<h3><label for="password">Password</label></h3>
<input id="password" type="password" name="password">
<label>
<input type="checkbox" name="rememberMe" value="1">
Remember me
</label>
<input type="submit" value="Login">
{% if errorMessage is defined %}
<p>{{ errorMessage }}</p>
{% endif %}
</form>
<p><a href="{{ url('forgotpassword') }}">Forget your password?</a></p>
User profile is similar. It's just HTML with with some CMS specific stuff.
It may look complicated when you first start but it's really not when you start to break it down.
One other thought I had is you're trying to give CMS authors/editors a way to throw those forms anywhere on the site, similar to how Freeform (or WordPress/Gravity forms) might do it.
That's probably more of a different answer, but one way to pull that off would be with a custom field such as a dropdown and some Twig templates to see which form the user selected. Then embed the appropriate form using Twig {% include %}
for example.
TLDR
I didn't even touch on Entry forms or User Profile but these are just as straightforward to code and setup. And you can always reuse code on other projects including any custom validators you setup.
I guess my point is if you're going to down the path of a custom module to hook into Freeform anyway, why not just cut out the middleman?
actionLogin()
method, and if unsuccessful, I could add errors to the response. However, I wasn't able to actually get a successful login; I'm clearly trying to hijack things and theactionLogin()
method wasn't intended to be used this way. Oh well, it was a fun exercise. The route I'll end up taking is using the Craft/Yii validation framework to extend validation rules as I need. I appreciate all the input. – Garrett Aug 8 '20 at 1:12