Jump to content

Settings Factory


Macrura

Recommended Posts

On 10/5/2020 at 8:26 AM, gmclelland said:

@gornycreative - If you are using Cloudflare - you may want to set some rules as seen here:

 

That's good. I was early on with cloudflare and have only recently gotten back into it to see how incredible their platform has grown to.

I had a pull the levers push the buttons fire drill prior to core updates but it looks like this may help that situation a lot! Thanks.

Link to comment
Share on other sites

  • 7 months later...

There should be examples of fieldsets defined in the samples folder, but using PHP. I don't think you can do fieldsets fro JSON defined settings, but the tabs fieldsets example shows "Advanced Settings" which are each in a fieldset.

sf-_tabs_fieldsets.thumb.jpg.c6ba20ebc22ff29c936b4eaf528251c0.jpg

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
  • 1 month later...
  • 6 months later...

@Clarity

Can you post the contents of your PHP file?
Are you using any namespace?
What version of ProcessWire are you on?

There is an example settings file in the module, you can copy to your templates folder somewhere and then specify that file for the settings. If that file doesn't work, then something must have changed in the core. It works for me under PW 3.0.178.

Link to comment
Share on other sites

Thank you! Finally, I found the root of the problem. I didn't add "return $inputfields;" to the end of file.
 
I'm not using a namespace explicitly. ProcessWire version is 3.0.199 dev, and everything works fine now.
  • Like 1
Link to comment
Share on other sites

53 minutes ago, Clarity said:
Thank you! Finally, I found the root of the problem. I didn't add "return $inputfields;" to the end of file.
I'm not using a namespace explicitly. ProcessWire version is 3.0.199 dev, and everything works fine now.

awesome! Thanks for using the module - hope it helps and is useful!

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

@Clarity - Settings Factory should technically support what any module config would; i've never seen repeater fields used in a module config screen, probably because repeaters require the use of hidden pages. So for now this module would need to stay limited to those fields whose values can be stored in text/json;

  • Thanks 1
Link to comment
Share on other sites

On 7/15/2022 at 10:04 AM, Clarity said:

Thank you about the information! Can you please tell whether it is possible to use ProField: Multiplier for this module? I'm getting an error "ProcessSettingsFactory: Fieldtype is not set".

when you do the code to add it, you would need to specify the Fieldtype to multiply, so that needs to be one of the options,

'fieldtypeClass': 'FieldtypeText' in the json or wherever...

(haven't tested this, but looking at the module, it does need the "fieldtype to multiply" to be expressly set)

  • Like 1
Link to comment
Share on other sites

Thanks for the advice, but it doesn't work for me. The error remains the same. My settings/settings.php is like that:

<?php
 
$inputfields = array(
    array(
        "name" => "emails",
        "label" => "Emails",
        "type" => "InputfieldMultiplier",
        "fieldtypeClass" => "FieldtypeText",
        "schemaClass" => "FieldtypeText",
        "qtyMin" => 3,
        "qtyMax" => 6,
        "width" => "100",
        "description" => "",
        "collapsed" => 0,
        "placeholder" => "",
        "columnWidth" => 50
    ),
    array(
        "name" => "phones",
        "label" => "Phones",
        "type" => "InputfieldMultiplier",
        "fieldtypeClass" => "FieldtypeText",
        "schemaClass" => "FieldtypeText",
        "qtyMin" => 3,
        "qtyMax" => 6,
        "width" => "100",
        "description" => "",
        "collapsed" => 0,
        "placeholder" => "",
        "columnWidth" => 50
    )
);
 
return $inputfields;
 
Can you please say what I'm doing wrong?
Link to comment
Share on other sites

I have no idea if it will work – module config fields can't use a database table, they have to be able to store in JSON, so it would take some research and experimentation to see if it is even possible to use this field type in a module config. So setting schemaClass would have no effect.

Most module configs that use repeatable interfaces are done with custom javascript, as far as I have seen. (For example use a text field for the first one, and then a hidden field to store the repeatable values; use JS to allow the users to add an inputfield, and then join all of the values together in pipe delimited hidden field..)

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

I have a weird issue, some values aren't saved. There is no error or whatever, it actually says: Saved: Einstellungen (that's the name of my page), but after saving, the field is empty again. The same file (the php file with all the custom fields that is needed for the settings-factory to work) works on a different PW installation, but not here. Any ideas why?

EDIT: I uninstalled and reinstalled the module, now not one value gets saved on my custom settings factory page. Still with no error, just the success message: Saved: Einstellungen

Might that have to do with some php settings? Thanks for help!

Link to comment
Share on other sites

Hi @fruid - sorry to hear about this! Could you send me the PHP file to have a look at it? Also let me know your PW, PHP and MySQL versions and i'll take a look. You never know, something could have changed with the PW version or PHP 8, and we need to make sure this module keeps working!

- Marc

  • Like 1
Link to comment
Share on other sites

58 minutes ago, Macrura said:

Hi @fruid - sorry to hear about this! Could you send me the PHP file to have a look at it? Also let me know your PW, PHP and MySQL versions and i'll take a look. You never know, something could have changed with the PW version or PHP 8, and we need to make sure this module keeps working!

- Marc

hi, thanks for getting back, I think I know where the issue is, I posted about it somewhere before. The issue must be, that my page using the SettingsFactory-process is hidden. If it's hidden, it cannot save values, only if it's unhidden it can save.

Link to comment
Share on other sites

  • 3 months later...

This module has been very useful. As I have been playing around more with module configurations for my own work I have started using $wire->file methods to find files and populate options for dropdowns for my modules.

Regarding Settings Factory, I have set manual select options in the past, but it would be great to know if logic can be placed in the settings file to generate options using wire objects.

I realize the PHP style settings factory configuration file uses InputfieldWrapper, etc. The settings file itself isn't namespaced and doesn't seem to instantiate anything. $wire->file itself, in the context of the settings file, seems to be null.

Are there any objects available to use to manipulate file via the wire object (find files, grab config paths), or would I need to write those functions with php?

Have you used logic to dynamically build select options?

Thanks again! ~J

Link to comment
Share on other sites

@Macrura sorry I meant $wire->files... I did end up finding a way to do what I needed to although I came across a few interesting issues that I can't really explain.

The functions were from a module context, so I had to pull them abstract them away from $this and just tried to manipulate them directly, since it seemed like a $wire object should still exist.

When I ran a db($wire->files) the bar dump said that this did represent a WireFileTools object, but the find() method was faulting, saying that the object was null when I tried to use $wire->files->find($something, $somewhere). Are the API helpers only available in certain contexts?

What I ended up doing was the following:

First, I brought my functions into a separate _theme_fn.php file. If I included them in the main Inputfields generating file, I got a cannot redeclare error, perhaps the settings factory config file is iterated in some way. I put both my settings factory config file and the external functions file in the PW namespace.

Second, in the external functions file I brought in a $wf = wire('files') and $wc = $wire('config') to the functions which allowed me to grab default paths, run the file searches and create the appropriate select options arrays.

Third, in the main settings factory file, did an include_once on the functions file and then I just set variables to call those functions and then inserted that into options.

This lets me generate select options arrays dynamically.

If you want a concrete example, let me know.

It is hard for me to determine sometimes whether I am able to use an API variable or have to actually call functions to create my own object on the customization side. Front end side and modules seem much clearer.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...