Jump to content
NorbertH

Strange behavior exporting fields

Recommended Posts

I have trouble exporting fields via the buildin export. 

For example when i export a single field  i get:

{
    "bestellung_status_name": {
        "id": 194,
        "type": "FieldtypeText",
        "flags": 0,
        "name": "bestellung_status_name",
        "label": "Status Intern",
        "textformatters": [
            "TextformatterEntities"
        ],
        "collapsed": 0,
        "minlength": 0,
        "maxlength": 100,
        "showCount": 0,
        "size": 0,
        "pattern": "[a-z\\A-Z\\(\\)]+",
        "showIf": "",
        "themeInputSize": "",
        "themeInputWidth": "",
        "themeOffset": "",
        "themeBorder": "",
        "themeColor": "",
        "themeBlank": "",
        "columnWidth": 100,
        "required": "",
        "requiredAttr": "",
        "requiredIf": "",
        "stripTags": "",
        "placeholder": ""
    }
}

exporting a secon single field i get :

{
    "bestellung_status_name_ext": {
        "id": 195,
        "type": "FieldtypeText",
        "flags": 0,
        "name": "bestellung_status_name_ext",
        "label": "Status Extern",
        "textformatters": [
            "TextformatterEntities"
        ],
        "collapsed": 0,
        "minlength": 0,
        "maxlength": 100,
        "showCount": 0,
        "size": 0,
        "pattern": "[a-z\\A-Z\\(\\)]+",
        "showIf": "",
        "themeInputSize": "",
        "themeInputWidth": "",
        "themeOffset": "",
        "themeBorder": "",
        "themeColor": "",
        "themeBlank": "",
        "columnWidth": 100,
        "required": "",
        "requiredAttr": "",
        "requiredIf": "",
        "stripTags": "",
        "placeholder": ""
    }
}

So far everything works fine .

When i try to export both fields together  i get only an error message :

Call to a member function getModuleInfo() on null 
File: .../wire/modules/Fieldtype/FieldtypeText.module:171

I added " bd($textformatter);" on line 170 to see whats wrong. so have a look at the screenshot i apended to this post.

 

Its perfectly possible that one textformater module got removed by accident while experimenting whith some textformaters but my question is how to fix this maybe somewhere in the DB and possibly what went wrong?

ProcessWire 3.0.120 © 2019
Apache/2.4.25 (FreeBSD) OpenSSL/1.0.2k mod_fcgid/2.3.9
PHP 7.1.2

   

 

Screenshot (1).png

 

Edit: After adding

if ($textformatter ===NULL) continue;

I can export my fields , as there arent any Textformater missing in the fields , i get a perfect result. but still there is one textformater whith a NULL value.  

 

 

Share this post


Link to post
Share on other sites

You could follow or show to us the full stack trace to see which Textformatter is being called.

Are they all set in the field option / details tab ? if yes, you might from there compare which one is missing ?

  • Like 1

Share this post


Link to post
Share on other sites

there is none missing in the fields ... is there a way to print out the full stacktrace ?

OR does i need to go for a very big screenshot ?

 

Share this post


Link to post
Share on other sites

FeildtypeText.module  line 161 ff

		if($this->allowTextFormatters()) {

            $textformatters = $this->modules->find("className^=Textformatter");

            if(count($textformatters)) {

                $f = $this->modules->get('InputfieldAsmSelect');
                $f->setAttribute('name', 'textformatters');
                $f->label = $this->_('Text Formatters');

                foreach($textformatters as $textformatter) {
                    bd($textformatter);
                    $info = $textformatter->getModuleInfo();
                    $f->addOption($textformatter->className(), "$info[title]");
                }

                $f->setAttribute('value', is_array($field->textformatters) ? $field->textformatters : array());

                $f->description = $this->_('If you want to apply any automatic formatting to the field when it is prepared for output, select one or more text formatters above. If you select more than one, drag them into the order they should be applied.');
                $f->notes = $this->_('For plain text fields that will not contain HTML or markup, we recommend selecting the **HTML Entity Encoder** option above.');

                $inputfields->append($f);
            }
        }

As far as i understand this he fetches all  existing textformater modules for each field  and as you can see in the screenshot , the last one is NULL as you can see in the screenshot.

Share this post


Link to post
Share on other sites

Ok here we go , made it black and white and indexed colors to get a smaller file .

Error_ Call to a me_ - https___test.futuresteam.de_futura_setup_field_export_.png

Share this post


Link to post
Share on other sites

In the DB there seem to be no invalid entry.  All Textformater entries look ok , and there are no invalid entries

in the whole modules table. 

db_shot_textformaters.png

Share this post


Link to post
Share on other sites

Have you tried:

bd($textformatter, $field->name);

so you can see which one at the end there is returning null? If you know the field affected, you might be able to check which textformatters are assigned to the field and find the problem that way.

  • Like 2

Share this post


Link to post
Share on other sites

PS - when you have found the field in question, check out the Field settings in the RequestInfo panel to see if there are any textformatters showing there that are null or empty or something.

image.png.8f147bfc85f6a7f287f1e23f252cb32d.png

  • Like 2

Share this post


Link to post
Share on other sites

Hi again, problem solved(hopefully)

using

bd($textformatter, $field->name);

I found that always after the second field  the last element of $textformatters contained a NULL Element. 

Checking the name of the textformater i found that this always hapened  to this formatter "TextformatterOnly0To9"

After taking a really close look i found that the classname differed from the filename:
"TextformatterOnly0To9"
"TextformatterOnly0to9"

Its only a upper/lower case difference and PHP (as far as i know) normally does not care about that in classnames.

Changing this back lets me reproduce the issue. Still one thing i don't understand is the fact that exporting one field works perfect, i can't get the point why only fetching $textformatters a second time leads to this issue. Btw. i did not experience any other issues whith that wrong named classname  the textformater did what he was expected to do....     

  • Like 2

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DV-JF
      Hey all, hope you're feeling well these days!
      Short question: Under "Setup > Templates" it's possible to sort the templates by last modified. Is this possible for fields view to?
      Long explanation:
      Currently I am in the process of programming a reusable template and often have to copy several fields & templates from different PW installations into my "master version".
      Therefore it would be good to see already in the field list when the last modification has taken place.
      Stay healthy & don't forget to wash you hands - many greets!
    • By Lmwt
      Hi forum,
      I have this list of fields with labels and I want to skip the displaying of labels for fields left empty (e.g. if field "logo" is not filled with an image, but it could also be text fields). Using count() and "continue" will always output either nothing or all labels.
      Is there a way to use the "skipLabel" method in the loop?
      foreach ($page->template->fields as $field) { if(!count($page->$field->logo)) {continue;} else { $etikette = $field->getLabel(); //get label in the current user language $content .= " <br><li class='pub-field'>$etikette<br> </li>"; //display labels as li $content .= $page->get($field->name) . "<br>"; // display values as li } } Thanks for your help!
    • By Lmwt
      Hello,
      and one more beginner question: I am using the multi-language site profile and having troubles targeting the region I want to populate in my templates due to delayed output. The list is now appearing on top of the nav bar 🙂 and the values of the fields on one line down the title. I want these fields to be displayed in a list underneath the title of the page, and I also would like the name of the field to be displayed as a string in front of the value... I dont know how to do this. Can someone help?
      right now my code looks like this: 
      <?php namespace ProcessWire;?> <!DOCTYPE html> <html> <li class="Pub-profile-info"><?php $content .=page()->Location?></li> <li class="Pub-profile-info"><?php $content .=page()->Pub_country?></li> <li class="Pub-profile-info"><?php $content .=page()->Since?></li> <li class="Pub-profile-info"><?php $content .=page()->Contact?></li> <li class="Pub-profile-info"><?php $content .=page()->Focus?></li> <li class="Pub-profile-info"><?php $content .=page()->Members?></li> <li class="Pub-profile-info"><?php $content .=page()->Location?></li> <li class="Pub-profile-info"><?php $content .=page()->Decision_making?></li> <li class="Pub-profile-info"><?php $content .=page()->Financing?></li> <li class="Pub-profile-info"><?php $content .=page()->History?></li> <li class="Pub-profile-info"><?php $content .=page()->images?></li> <li class="Pub-profile-info"><?php $content .=page()->logo?></li> </html> and the screen looks like that:
      Thanks for helping!

    • By dragan
      Is it by design that a site/ready.php is not included when creating a new site profile? Is it possible to include it with a hook? Or are there any security thoughts? (I don't want to redistribute it in public, it's just so I have my own boilerplate)
    • By louisstephens
      So I was tinkering around with the "select fields" field type and added it to a repeater. My thoughts were I could have a user select a field (textarea, text, etc etc) that I defined and give it a name (another field in the repeater) and create their own form on the page. To be honest, I am now a little lost with rendering the form and mailing the results as potentially the form will be unique and custom every time.  The only way I know to handle the output is by going about it this way:
      $forms = $page->form_select_fields; foreach($forms as $form) { if($form->name === "form_input") { //output input with custom name } elseif($form->name === "form_textarea") { //output input with custom name } } Is there a better way to go about rendering the elements from the repeater? As far as the custom sending goes, I am really at a loss since it would be pretty dynamic. Has anyone used this type of approach, and if so, how did you handle this without going insane?
×
×
  • Create New...