Skip to main content

Questions tagged [modules]

Questions related to Craft 3 Yii Module Development

28 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2 votes
0 answers
259 views

getDirtyFields returning more results than expected

I have a module that sends an email whenever a specific entry field is updated. Everything is working fine except that the field is being passed to the dirtyFields array even if it has not been ...
Jorge Sosa's user avatar
2 votes
0 answers
260 views

Conditionally attach behaviors to craft\elements\Entry by section

I'm trying to conditionally attach behaviors based on an entries section. The following code works fine, but I'm trying to clarify one bit: To avoid a yii\base\InvalidConfigException on the CP ...
Tim Kelty's user avatar
  • 3,081
1 vote
0 answers
636 views

Invalid Route in module

I'm new to craft and slowly learning how to use more advanced features. I'm trying to write a module with a controller. When the route is invoked on a fetch call I get the following error: HTTP 404 – ...
mauricio's user avatar
  • 187
1 vote
0 answers
939 views

Request didn’t meet the user agent and IP requirement for maintaining a user session when website posts to our action URL

We have a module that has an action controller method that a third party website posts data to. We can see that often, we can't save the data and there is an error "Request didn’t meet the user ...
John's user avatar
  • 974
1 vote
0 answers
42 views

Show parents of entry in custom entries field extending BaseRelationField

The default BaseRelationField shows only the name of the selected entry in the field (e.g. "SubEntryX"). I created a custom entries field by extending the BaseRelationField in a module. Now ...
Bobby's user avatar
  • 11
1 vote
0 answers
396 views

Save and log in a user from event callback

I'm trying to build a plugin wherein after a user is created via the normal means via a front end template, the user is immediately logged in. My module is watching for the after save event on ...
MikeJ's user avatar
  • 11
1 vote
0 answers
242 views

How can I override the Response status text from a controller?

I'm trying to set the statusText in a response, from a module controller. E.g.: <?php namespace modules\appmodule\controllers; use Craft; use craft\web\Response; class StatusController extends ...
Tim Kelty's user avatar
  • 3,081
1 vote
0 answers
90 views

Craft Commerce Adjuster API/PHP questions

I've got a module set up to add discounts based on criteria defined in a category group (handle 'productPacks') -> category (which is a "pack"). Now, everything works great for one type of pack, and ...
Anders's user avatar
  • 652
1 vote
0 answers
548 views

How do I correctly upload a new Asset from a temp file I generated from a service method?

Preamble Craft 3.1.26 PHP 7.2.8 on Mamp Pro 5.1.1 I browsed to my storage/reports folder and made sure in Finder than full read/write privileges are granted. What's goin on I have a module with a ...
Steven Thate's user avatar
1 vote
0 answers
69 views

Looping over categories, product variants, and subsequently applying adjuster(s)?

Using the Craft 3 and Commerce 2 APIs, how would one go about looping through products in the cart to apply adjusters, looking at the following example; A category, "Product Packs" is set up where ...
Anders's user avatar
  • 652
1 vote
0 answers
238 views

How do I use a relation field in an element?

Currently I have a field that extends BaseRelationField, and 2 types of elements. I want the field on elements A to be able to select from elements B. So far the field itself works, which I tested by ...
bastiaanwuisman's user avatar
1 vote
0 answers
82 views

Installing module via composer

I followed this question like: ... "repositories": [{ "type": "vcs", "url": "[email protected]:jorgeanzola/mymodule.git" } ], ... "require": { "craftcms/cms": "^3.0.0", ... "...
Jorge Anzola's user avatar
1 vote
0 answers
72 views

Get fields of requested entry in module

Instead of writing a lot of logic in twig in my template, I tried to create a service and get the fields related to the requested entry in a module. I then want to create a new twig variable to output ...
mcoze's user avatar
  • 11
0 votes
0 answers
20 views

Custom Dropdown/Selectize Field Type

This is a question in Craft 5. I want to create a field type to pull in all of the Sections and display them in a Dropdown/Selectize Field. I've got that showing ok with this: protected function ...
supazu's user avatar
  • 526
0 votes
1 answer
48 views

EVENT_REGISTER_SITE_URL_RULES not working

I have created a custom module and registered a route like this. EVENT::on( UrlManager::class, UrlManager::EVENT_REGISTER_SITE_URL_RULES, function (...
Matthias's user avatar
  • 301
0 votes
0 answers
31 views

How to clear conditional field values when hidden?

In Craft CMS 5, I have several conditional fields that display or hide based on the value of a Category field (single selection). Depending on the selected category, different fields appear: Date, ...
Romain P.'s user avatar
  • 1,852
0 votes
0 answers
36 views

Save provisional changes in custom controller

I have added a button to the entry edit page, which runs a custom controller I user to copy data from field A into field B in a particular format. Here's a condensed version of that: public function ...
supazu's user avatar
  • 526
0 votes
0 answers
21 views

Change layout of relations field in cp "Unable to find the template"

I've created a custom module that adds form submissions as relations to the entry they were submitted on. This functionality works, but I can't figure out how to change the template for the relations ...
Jane's user avatar
  • 11
0 votes
0 answers
26 views

Is there any events to trigger for inserting data into orderAdjustment table

I'm implementing a module to integrate a third party gift voucher into the craft cms application. For that I need to trigger the order Adjuster every time the cart gets updated. TIA
Gowri Shankar's user avatar
0 votes
0 answers
34 views

Is it possible to change built-in field like Table with a module?

Is it possible to change behavior of in-built field with a module? I am trying to change // Apply static translations part of _normalizeValueInternal function in Table.php https://github.com/craftcms/...
Foxtrot's user avatar
0 votes
0 answers
49 views

Class "modules\jobs\GenerateSocialCard" not found

Following this article, I'm trying to generate an image from html on Entry Save, but I'm getting an error when trying to push a job GenerateSocialCard to the Craft queue. I'm using the default Module. ...
Michal Bulla's user avatar
0 votes
0 answers
100 views

How to save the selected assets in custom module

I am trying to create a custom module where I have created an asset uploader field. Images are getting uploaded with that field but not saved. class Settings extends Model { // Public Properties ...
Eira's user avatar
  • 1
0 votes
0 answers
517 views

Form with controller action, not working on Safari only (!)

Got a problem with a module. It functions in Firefox and Chrome, but not in Safari. It seems that the action fired from the form doesn't even call the controller, the page just reloads. ...
mauricio's user avatar
  • 187
0 votes
0 answers
355 views

Passing variables, and reading them, to Module template

I'm trying to pass an array to a module's twig template (on the front end). I have tried many solutions I've seen here, but I'm not able to read the passed variables inside the twig template. In my ...
mauricio's user avatar
  • 187
0 votes
0 answers
97 views

How to convert custom plugins to custom modules

I have 3 custom plugins that we had someone develop for us a while ago and I would like to convert them to custom modules. Since plugins are based upon modules, I was hoping there might be a cookbook ...
Wildhorse's user avatar
0 votes
0 answers
87 views

At what point is siteId set for orders?

I have an adjuster I am trying to get to work, but the order has to come from a specific site in order for the adjuster to be applied. The siteId is 2, but when I try to get the siteId from the Order ...
Darryl Hardin's user avatar
0 votes
0 answers
318 views

How to exclude some fields from the searchindex using the RegisterElementSearchableAttributesEvent event?

Context I had big issues on a Craft 2 multilingual site with dozens of thousands of entries that were using Matrix fields. The site had become extremely slow (almost unusable), especially when ...
Romain P.'s user avatar
  • 1,852
0 votes
0 answers
42 views

Is there a callback for post Craft 3 CMS installation I can use?

I was hoping to have my module create a few fields, sections, and entries after the Craft 3 CMS has completed it's installation. Is there a callback I can listen to that triggers after the CMS is ...
Mark Notton's user avatar
  • 2,337