Jump to content

[solved] New field is not added


Recommended Posts

I moved a site to a new home and ran into a "strange" issue:


No field is added. I have no error message "anywhere", not in the console, no PHP, not in server logs either.

The strange thing is that I can Duplicate fields: Setup > Fields > Actions > Duplicate/clone this field?
Meaning it is just the "Add New Field" which does nothing. I can also create pages.
Also,  "Add New Field" does work in local development environment (same site and "same state", of course), it is just the new server environment which is problematic.

Any ideas for troubleshooting? Thanks in advance :)

Link to comment
Share on other sites

Looking at ProcessField.module, this is where a field is saved

// ProcessField.module

public function ___executeAdd() {

    // unrelated shortcut feature: double check that all field tables actually exist
    // and re-create them in instances where they don't (like if a bunch of fields
    // were migrated over in an SQL dump of the "fields" table or something). 

    return $this->executeEdit(); 

public function ___executeEdit() {
    // ...
    if($this->field->id) {
        $headline = sprintf($this->_x('Edit Field: %s', 'edit headline'), $this->field->name); // Headline when editing a field
    } else {
        $headline = $this->_x('Add New Field', 'add headline'); // Headline when adding a field
    // ...
    return $out;

And this is the checkFieldTables() method

protected function checkFieldTable(Field $field) {
    // if(!$this->wire('config')->debug) return;
    $database = $this->wire('database'); 
    $table = $database->escapeTable($field->getTable());
    if(empty($table)) return;
    $exists = $database->query("SHOW TABLES LIKE '$table'")->rowCount() > 0;
    if($exists) return;
    try {
        if($field->type && count($field->type->getDatabaseSchema($field))) {
            if($field->type->createField($field)) $this->message("Created table '$table'"); 
    } catch(\Exception $e) {
        $this->trackException($e, false, $e->getMessage() . " (checkFieldTable)"); 

Here I can deduce:

  • There's something wrong with the field table, it already exists but PW cant associate the field with its id/table?
  • $field->type is empty string or field does not return a schema.

Having null fieldtype probably means something wrong with the Module cache, refreshing cache may help.

Going forward, this is how field table is created

public function ___createField(Field $field) {

    $database = $this->wire('database');
    $schema = $this->getDatabaseSchema($field); 

    if(!isset($schema['pages_id'])) throw new WireException("Field '$field' database schema must have a 'pages_id' field."); 
    if(!isset($schema['data'])) throw new WireException("Field '$field' database schema must have a 'data' field."); 

    $table = $database->escapeTable($field->table); 
    $sql = 	"CREATE TABLE `$table` (";

    foreach($schema as $f => $v) {
        if($f == 'keys' || $f == 'xtra') continue; 
        $sql .= "`$f` $v, "; 

    foreach($schema['keys'] as $v) {
        $sql .= "$v, ";
    $xtra = isset($schema['xtra']) ? $schema['xtra'] : array();
    if(is_string($xtra)) $xtra = array('append' => $xtra); // backwards compat: xtra used to be a string, what 'append' is now. 
    $append = isset($xtra['append']) ? $xtra['append'] : '';

    $sql = rtrim($sql, ", ") . ') ' . $append;
    $query = $database->prepare($sql);
    $result = $query->execute();

    if(!$result) $this->error("Error creating table '{$table}'");

    return $result; 

From here it seems you'd get an error if table couldnt be created, so no issues with table creation. Also you've mentioned that duplication works fine.

These are somewhat obvious deductions from the source code.  But, to me, everything points to fields table in the DB. 

  • Like 2
Link to comment
Share on other sites

Thanks @abdus for taking a look at it!

24 minutes ago, abdus said:

probably means something wrong with the Module cache, refreshing cache may help

Unfortunately it did not help. I also tried cleaning all the other ProcessWire cache just in case but it did not help either.

However, since initially I forgot about refreshing the module cache, you gave me the idea to refresh the browser cache too (Chrome: Empty cache and hard reload).

And this one did help!

I still find it strange that this was the issue but browser caches can lead to troubles :) Thanx once more!

Edited by szabesz
  • Like 1
Link to comment
Share on other sites

Glad to help :)

I'm intrigued, though.
I thought Empty Cache and Hard Reload affected just the asset/file cache. Does chrome cache redirects too? Or how can file cache stop fields from being saved?


Also, a useful hook to keep around. To refresh module cache on superuser login:

$this->addHookAfter('Session::loginSuccess', function (HookEvent $e) {
    /** @var User $user */
    $user = $e->arguments('user');
    if ($user->isSuperuser()) {


  • Like 1
Link to comment
Share on other sites

5 hours ago, abdus said:

Or how can file cache stop fields from being saved?

I have a clue, it might help us in understanding what could have happened:
Normally, when we are on the first step page of "Add New Field" we have breadcrumb Admin > Setup > Fields with "Fields" linking to example.com/admin/setup/field/
However, right before clearing the browser cache I noticed that after the failed field adding attempt, it was linking to: example.com/admin/setup/field/add/ and that also made me suspicious :)

I'm guessing here but all this might be related to the fact that the site was moved. I cannot explain why though...

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Marc H.
      Hello folks,
      I have a strange problem.
      I have enabled the frontend editing plugin for a website, so that customers are given the ability to customize an assigned page to their liking.
      However, the problem occurs that by double clicking the elements, to edit the content, those dialogues are opened multiple times.
      Since I have recently started using the markup regions, I suspect that there is a connection here and certain elements are being outputted twice, whereby the trigger for editing elements is set twice.

      I'm not sure, what type of informations you'll need to debug this issue, or where to start looking.

      I'd be grateful if you'd be able to support me, in finding the issue and solving my problem.
      Thanks in advance.

    • By sambadave
      Hi there
      Short version of question
      Let's say I have a page in the admin that contains a field... Is it possible to output the content from that field on another page in the admin? Almost like a reference.
      Longer version of question (with example)
      A house builder with multiple (60+) developments. They want to be able to create notices/messages that can be added to one or many developments. Handy for things like regional covid lockdowns or temporary office closures due to bad weather.
      My approach for the admin editing options:
      Add each message to each development
      Pros: You edit the message on the development page in context
      Cons: Very time consuming and repetitive if the same message needs to be applied to 60+ developments
        Control all the messages from one admin page and say which development each message should be applied to
      Pros: Easier to add/remove messages to more than one development at a time. Control all messages from one place.
      Cons: Content is not added on development page, which is where typical admin users may expect to find it I went for option 2 due to flexibility, and created a page within the admin for global development notices. This contains a repeater with:
      Field for message to display Checkbox list of all developments. The user can select which ones to apply each message to It's working really well but the only thing is that if the user goes to a specific development in the admin, the relevant messages aren't displayed in context (as they aren't edited on that page and instead on the global development notices page)... which may cause confusion when a new staff member / content admin tries to edit the text but there is no field when they go to the development admin page where they expect to see it...
      I don't require the message(s) to also be editable on the development page, but I wondered if there was a nice way to show it/them somehow. I feel like I am missing something really simple as I'm sure ProcessWire will have a nice way of achieving this, or maybe there are field settings that allow this kind of thing to happen?
      Any ideas on approaches or similar experiences would be much appreciated, even if it is just a much simpler example with the content from one field being shown on another admin page to get the ball rolling.
      Thanks in advance for any advice :)
    • By daniel_puehringer
      Hi community, thanks for the great work you do 🙂

      I´m looking for a global field which can be used in the footer and has only one instance for all pages. So I´m kind of looking for "One field to rule them all".
      Reason for my question: The website I´m currently building has one footer for all pages. The content of the footer should be dynamic - therefore I made a global field which is automatically inserted into each page.
      Problem: if I want to change something in the footer, I have to do it for all fields, because each field has it´s own instance.

      Question: is it possible to have one global field in which changes the content for the footer of all pages?

      In most CMS Systems a simple solution to this is often impossible, I hope that processwire is different 🙂

      All the best,
    • By Pip
      Hi, Everyone! 
      I'm currently working on a page reference field and set it for multiple pages (AsmSelect) for the input. Is there a way for me to add an image field (aka Avatar) and the title of page in the radio button? 
      I used the field name enclosed in the { }. Didn't work. It appeared a text instead. 
      Thanks in advance and hope to hear from you soon!
    • By EyeDentify
      Hello dear PW gurus.

      I have stumbled over a strange error that i all of sudden got when trying to upload an image to a images field on a page.
      There where images allready stored in the field that i wanted to keep, but during the upload the error apear and after that all images are gone from the field and i can´t upload any, i just get the error every time.
      I am running ProcessWire 3.0.153 dev.
      After looking in the assets folder i find the folder for the page and the image files seems to be there including the ones i tried to upload when the error occured.
      But they don´t show up in the images field in the page editor.
      The error reported:
      SQLSTATE[01000]: Warning: 1265 Data truncated for column 'ratio' at row 1 And here is a screenshot of the event:

      The TracyDebugger Error reporting:

      I hope you fine folks could point me in a direction.
      But it seems our old pal set_time_limit() is back.

      Regards, EyeDentify
  • Create New...