table part of a field not found with calclated field in php

table part of a field not found with calclated field in php

crcucbcrcucb Posts: 72Questions: 23Answers: 0

From the JS, serverside is set to false. I am trying to add a caclulated column in the php editor code:

Field::inst( '( select 1 ) ' , 'editorform') ->set( false )

the above is giving me :smile:
DataTables warning: table id=Residents - Table part of the field "( select 1 ) " was not found. In Editor instances that use a join, all fields must have the database table set explicitly.

Answers

  • allanallan Posts: 64,892Questions: 1Answers: 10,746 Site admin

    You are hitting this part of the code. Unfortunately it doesn't take account of doing something quite like you have. I'll need to have a think about that, possibly it could be as simple as checking for ( and accepting that the dev knows what they are doing. That check is really just a sanity check and could be commented out in your local code if you want to bypass it.

    Allan

  • crcucbcrcucb Posts: 72Questions: 23Answers: 0

    Ultimately, this is what I am trying to do and why. I have two different client-side editor forms that utilize the same php file named residents.php. In residents.php, when an edit / update is being posted, I call a sql Stored proc and pass $_POST which performs some behind-the-scenes edits. I want the stored proc to know which editor form the update originated from. I first tried to add a hidden field to the two editor definitions on the client side:

    var familiareditor = new DataTable.Editor( {
    ajax: 'php/residents.php',
    fields: [{ data: 'familiareditor', name: 'editorform', type: 'hidden' },....
    
    var residenteditor = new DataTable.Editor( {
    ajax: 'php/residents.php',
    fields: [{ data: 'residenteditor', name: 'editorform',type: 'hidden'  }....
    

    When I review the value of $_POST in residents.php, I have not been able to get a value to populate for field 'editorform':

    $_POST= {"data":{"128":{"Residents":{"phone":"(111) 222-3333","email":"thisismyemail@gmail.com","residentnotes":"","AddressAID":"126"},"userAIDIsFamiliar":"1","Comments":"","UpdateFamiliars":"","view_Residents":{"FullNameParty":"COMMANDER, ANDREA S (BLK)"},"UserAID":"9","editorform":""}},"action":"edit"}

    My thought was maybe because the field does not originate from the PHP, it won't accept any value (I was troubleshooting/trying stuff). So I was going to try to add a calculated field in the PHP and set a value on the client side, and evaluate.

  • allanallan Posts: 64,892Questions: 1Answers: 10,746 Site admin

    Ah - you just want an extra field in the JSON response?

    Field::inst('editorform')
      ->getValue(1)
      ->set(false)
    

    Should do it.

    However, there shouldn't be any need to do that given your description. You should be able to have a field:

    {
      name: 'editorform',
      def: ''
    }
    

    and it can be hidden or whatever, and not have a value in the original JSON.

    If that isn't working for you, drop me a link to the page yo are working on and I'll take a look.

    Allan

Sign In or Register to comment.