5

You're probably looking for Element::getDirtyAttributes() and Element::getDirtyFields()! The former is for native class properties/attributes (and is based on an ActiveRecord pattern in Yii, I believe...), and the latter is for Craft's "fields," which may or may not be available, based on what type of Element you're looking at (and what FieldLayout ...


3

You're passing false as the second parameter of your saveElement call... that parameter means you're skipping the built-in validation which should catch this error for you. If you get rid of that you should then receive a warning in the logs when processing existing users, but it shouldn't halt execution of the script.


3

Based on your goal, I don't recommend taking this approach for the technical debt reasons in my comment, however your actual question is still a valid one. You can call any controller's method from a plugin/module like this: Craft::$app->runAction('users/save-user');


2

Forgot to add the return keyword :( return $this->redirect('https://foobar.test');


2

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 ...


1

Alright! I've been able to fix my problem. I did a couple of things wrong so I'm writing this for whoever makes the same mistakes I made and is now trapped in an endless loop of despair and impending doom. First mistake! You should leave the action attribute of your form element empty. Call you action by using a hidden input, like this <input type="...


1

This will be possible as of the next Craft release, which will be 3.4.21: https://github.com/craftcms/cms/commit/a787fe0ef37841706a5a9910fbeae0391da3be6f


1

You'd do this wiht a Craft plugin or module. Try giving the plugin docs a once over: https://docs.craftcms.com/v3/extend and if you have some specific questions, feel free to post back. You can also generate Craft plugin boilerplate code at https://pluginfactory.io that already has a lot of this setup for you.


1

Try this: Craft::$app->getUrlManager()->setRouteParams([ 'variables' => ['order' => $order] ]);


Only top voted, non community-wiki answers of a minimum length are eligible