Jump to content

Mystique (Fieldtype, Inputfield) build dynamic fields and store data by using config file


ukyo

Recommended Posts

  • 1 year later...
5 hours ago, Ivan Gretsky said:

Good day @ukyo!

Is there a way to manipulate field data from the API? Like batch setting / changing it?

This should work

<?php

$page->of(false);

$page->mystique_field_name->property1 = 'data';
$page->mystique_field_name->property2 = 'data';
$page->mystique_field_name->property3 = 'data';
$page->mystique_field_name->property4 = 'data';
$page->mystique_field_name->property5 = 'data';
$page->mystique_field_name->property6 = 'data';

$page->save();
  • Like 1
Link to comment
Share on other sites

@Ivan Gretsky You can also try next version of Mystique field type.

Now, its possible to display custom fields depend on template name or page, you imagine it.

Here is an example usage:

<?php

namespace ProcessWire;

/**
 * Resource: magic of mystique field
 */
return function ($page = null, $field = null, $value = null) {

    $fields = [
        'hello' => [
            'label' => 'Are you ready for a Magic ?',
            'type' => 'select',
            'options' => [
                'no' => 'No',
                'yes' => 'Yes'
            ],
            'required' => true,
            'defaultValue' => 'no'
        ]
    ];

    if ($page instanceof Page && $page->template->name == 'page') {
        $fields['current_page'] = [
            'label' => 'Current page title : ' . $page->title,
            'value' => $page->title,
            'showIf' => [
                'hello' => '=yes'
            ],
            'columnWidth' => 50
        ];
    }

    if ($field instanceof Field) {
        $fields['current_field'] = [
            'label' => 'Current field label : ' . $field->label,
            'value' => $field->label,
            'showIf' => [
                'hello' => '=yes'
            ],
            'columnWidth' => 50
        ];
    }

    return [
        'name' => 'magician',
        'title' => 'Do A Magic ?',
        'fields' => $fields
    ];

};

 

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Hello, @ukyo!

Current variant of Mystique in "master" branch gives the error "You need to select a resource and save field before start to use Mystique." after creation of the page. I don't see that it is possible to select a resource just after creation of the field. Switching to the branch "next" solves the problem.

In addition, Mystique will search files in form Mystique.*.php in site/templates/configs, not in site/templates.

Link to comment
Share on other sites

Quote

In addition, Mystique will search files in form Mystique.*.php in site/templates/configs, not in site/templates.

Yes, json or php file. I see my mistake on readme.md i will fix it.

{Mystique.*.php,mystique.*.php,Mystique.*.json,mystique.*.json}

 

Quote

Current variant of Mystique in "master" branch gives the error "You need to select a resource and save field before start to use Mystique." after creation of the page. I don't see that it is possible to select a resource just after creation of the field. Switching to the branch "next" solves the problem.

Long time i am not working with master branch, i have many updates on next branch, i will merge these 2 branch soon.

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

1 hour ago, Clarity said:

Somewhy when I save a page with fields given by Mystique, content from these fields disappear after saving. Is it a problem with next branch?

I have many web projects using mystique fields, i didn't see an error like this. You can make a try with clean processwire install, after that if this error continue for your create an issue on github repo.

  • Like 1
Link to comment
Share on other sites

9 hours ago, Clarity said:

I found the root of the problem. The checkbox "Group fields inside fieldset" was unchecked, and it leads to values of fields being unsaved.

I think I had this issue as well in some version of Next a few months ago and downgraded.  Sorry I can't provide more details at the moment.

Link to comment
Share on other sites

20 hours ago, Ivan Gretsky said:

Hey @ukyo!

Every time I write here I want to start with a thank you, as I like the module so much)

Now to the question. Is it possible now or could it be implemented to support repeater / repeater matrix fields?

P.S. Are  there any rumors about when is the next branch going to be merged?

Mytqiue works inside repeater fields.

If you mean, create repeater field via Mystique, the answer is no.

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