mecha-cms / x.panel

Control panel feature.
Other
6 stars 0 forks source link

Field problems with YAML block sequences #16

Closed igoynawamreh closed 4 years ago

igoynawamreh commented 4 years ago

I'm having problems creating custom field to create sequences data.

Example data:

---
links:
  - title: Link 1
    link: 'https://example.com/1'
  - title: Link 2
    link: 'https://example.com/2'
...

Hook to the panel to create the links field:

Hook::set('_', function($_) {
    $links_content = <<<HTML
        <div>
            <input class="input" name="page[links][0][title]" placeholder="Title" type="text">
            <input class="input" name="page[links][0][link]" pattern="^(data:[^\s;]+;\S+|(https?:)\/\/\S+)$" placeholder="http://localhost" type="text">
        </div>
        <div>
            <input class="input" name="page[links][1][title]" placeholder="Title" type="text">
            <input class="input" name="page[links][1][link]" pattern="^(data:[^\s;]+;\S+|(https?:)\/\/\S+)$" placeholder="http://localhost" type="text">
        </div>
    HTML;

   $_['lot']['desk']['lot']['form']['lot'][1]['lot']['tabs']['lot']['page']['lot']['fields']['lot']['links'] = [
       'type' => 'field',
       'content' => $links_content,
    'stack' => 10
    ];
    return $_;
});

Update: the links field is shown, but I can't Publish or Update the page (the panel stuck on uploading).

taufik-nurrohman commented 4 years ago

For debugging:

  1. Go to .\index.php then set the DEBUG constant value to true.
  2. Go to .\lot\x\panel\state.php then set the fetch option to false.

Give me the error log shown.

igoynawamreh commented 4 years ago

Go to .\state.php then set the DEBUG constant value to true.

Did you mean .\index.php?

igoynawamreh commented 4 years ago

The error log:

Warning: trim() expects parameter 1 to be string, array given in E:\xampp\htdocs\mecha\mecboots\lot\x\panel\engine\r\task\g.php on line 172

Warning: trim() expects parameter 1 to be string, array given in E:\xampp\htdocs\mecha\mecboots\lot\x\panel\engine\r\task\g.php on line 172

Notice: Undefined variable: dent in E:\xampp\htdocs\mecha\mecboots\lot\x\y-a-m-l\engine\plug\to.php on line 13

Fatal error: Uncaught TypeError: Argument 2 passed to Closure::{closure}() must be of the type string, null given, called in E:\xampp\htdocs\mecha\mecboots\lot\x\y-a-m-l\engine\plug\to.php on line 13 and defined in E:\xampp\htdocs\mecha\mecboots\lot\x\y-a-m-l\engine\plug\to.php:7

Stack trace:
#0 E:\xampp\htdocs\mecha\mecboots\lot\x\y-a-m-l\engine\plug\to.php(13): Closure->{closure}(Array, NULL)
#1 E:\xampp\htdocs\mecha\mecboots\lot\x\y-a-m-l\engine\plug\to.php(32): Closure->{closure}(Array)
#2 E:\xampp\htdocs\mecha\mecboots\lot\x\y-a-m-l\engine\plug\to.php(58): Closure->{closure}(Array, ' ')
#3 E:\xampp\htdocs\mecha\mecboots\lot\x\y-a-m-l\engine\plug\to.php(64): Closure->{closure}(Array, ' ', '\t')
#4 [internal function]: Closure->{closure}(Array, ' ', true)
#5 E:\xampp\htdocs\mecha\mecboots\engine\f.php(168): call_user_func(Object(Closure), Array, ' ', true)
#6 E:\xampp\htdocs\mecha\mecboots\engine\kernel\genome.php(24): fire(Object(Closure), Array, Object(To))
#7 E:\xampp\htdocs\mecha\mecboots\lot\x\page\engine\plug in E:\xampp\htdocs\mecha\mecboots\lot\x\y-a-m-l\engine\plug\to.php on line 7
taufik-nurrohman commented 4 years ago

Ah, look like this is a bug from the YAML extension.

taufik-nurrohman commented 4 years ago

Try with Mecha v2.3.1 and Panel v2.3.2 :+1:

igoynawamreh commented 4 years ago

Thanks

taufik-nurrohman commented 4 years ago

@igoynawamreh if you are just downloading the new Mecha core recently, please update! There is a small bug in the Hook class which eject the whole hooks instead of ejecting by context.