shannah / xataface

Framework for building data-driven web applications in PHP and MySQL
http://xataface.com
GNU General Public License v2.0
134 stars 57 forks source link

ckeditor widget does not save content when used inside a grid widget #118

Open patrr opened 3 years ago

patrr commented 3 years ago

In a 1:n relationship managed via a transient field and a grid widget in the main table, like this:

(table 'Punto': fields.ini)

[Testi]
transient=1
widget:type=grid
widget:columns="Tipologia, TitoloTesto, Testo, CodDelibera, Raccordo, NoteT"
relationship=Testi
order=40

(table 'Punto': relationships.ini)

[Testi]
__sql__ = "SELECT * FROM Testo T WHERE T.FKPunto='$KPunto'"

(table 'Testo': fields.ini)

[Testo]
widget:type=ckeditor
passthru=1

everything is rendering as expected when editing a 'Punto' record, but no value is saved in the 'Testi' relationship when clicking the save button, and no new line in the grid appears when clicking on the last cell

If a textarea widget is used instead of a ckeditor widget, like this:

(table 'Testo': fields.ini)

[Testo]
widget:type=textarea

the save button and the new line mechanism in the grid work again as expected.

ckeditor inside a grid might not be currently supported, but could sometimes be useful

patrr commented 3 years ago

Apparently something goes wrong when transferring the values from the form/widget to the record to be saved. As a matter of fact, 'beforeSave()' does not know the new values inserted, while 'pushValue()' does.

So I tried to short circuit the builtin transfer mechanism using the 'pouch' that XF provides, like this (in the 'Testi' table delegate class):

function Testi__pushValue(&$record, $el){
    //echo '<pre>'; var_dump($el->getValue('Testi')); die();
    $record->pouch=$el->getValue('Testi');
}

function beforeSave($record){
    $Testi=$record->pouch;
    //echo '<pre>'; var_dump($Testi); die();
    $record->setValue('Testi', $Testi);    
}

and it works, sort of.

I know it's not a solution, but if someone needs a bypass...