Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
patrr opened this issue Oct 31, 2020 · 1 comment
Open

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

patrr opened this issue Oct 31, 2020 · 1 comment

Comments

@patrr
Copy link
Contributor

patrr commented Oct 31, 2020

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
Copy link
Contributor Author

patrr commented Feb 24, 2021

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant