View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
18204Feature requestsPluginspublic2022-06-22 10:37
Reporterollehar Assigned Toollehar  
PrioritynoneSeverityfeature 
Status assignedResolutionopen 
Summary18204: New event: ExtendForm
Description
  • New event in development branch (not the epic branch)
  • Event is called extendForm
  • Plugin adds objects to the extendForm event
  • Object contains information about which type of input field it is
  • Object does NOT contain any HTML, that’s decided by the application using the event
  • Object also contains a function to save the POST data into database, for its input
  • Object implements an interface, e.g. ExtendFormInputInterface, so that other objects can be added later (for dropdown, date picker, select2 etc etc)
  • For any form, you need to fire the event twice: Once when the form is generated, and once when the form is submitted
  • Each form has an id used by the event, so that objects are attached to the correct form
  • Manual must be updated with new event page, so that other developers can use it
TagsNo tags attached.
Bug heat4

Users monitoring this issue

User List There are no users monitoring this issue.

Activities

ollehar

ollehar

2022-06-21 13:11

administrator   ~70423

Last edited: 2022-06-21 13:12

Ping @DenisChenu and @gabrieljenik if you're interested. We will work on this internally and initially only support global settings form and input checkbox.

Added to LS5 LTS, I guess (dev branch).

DenisChenu

DenisChenu

2022-06-21 14:20

developer   ~70424

You mean : for GroupSettings ? UserSettings ? near SurveySettings

Something related to an object with an id ?

https://manual.limesurvey.org/BeforeSurveySettings
https://manual.limesurvey.org/NewSurveySettings

ollehar

ollehar

2022-06-21 14:30

administrator   ~70425

This would be a general event for any form that supports it. So, one form event to rule them all. :)

DenisChenu

DenisChenu

2022-06-21 14:36

developer   ~70426

But : you need to review all existing form then ?

Before : need to review core form …

Each form has an id used by the event, so that objects are attached to the correct form

https://github.com/LimeSurvey/LimeSurvey/blob/baf7a27369fab4bb10bacb467790e046385da591/application/models/PluginSetting.php#L21-L22

ollehar

ollehar

2022-06-21 14:37

administrator   ~70427

Yeah, but we're just gonna support global settings for now. Rest are added when needed by a plugin author.

ollehar

ollehar

2022-06-21 14:39

administrator   ~70428

Last edited: 2022-06-21 14:39

$event->append('globalsettings', new ExtendFormCheckbox('input_id', function($post, $connection) { ... save logic here }));
DenisChenu

DenisChenu

2022-06-21 14:44

developer   ~70429

:(

To add 3elements

$event->append('globalsettings', new ExtendFormCheckbox('input_id', function($post) { ... save logic here }));
$event->append('globalsettings', new ExtendFormCheckbox('input_id2', function($post) { ... save logic here /* Same than previous*/ }));
$event->append('globalsettings', new ExtendFormCheckbox('input_id3', function($post) { ... save logic here /* copy/paste from previous*/  }));

I never have to update global settings ,

See how i do to create forum since some years now (and it work without update plugin …) : https://gitlab.com/SondagesPro/mailing/sendMailCron/-/blob/master/sendMailCron.php#L1403

We already hae 2 form constructor : one for Survey and one for QuestionAttribute.
You add another one …

ollehar

ollehar

2022-06-21 14:52

administrator   ~70430

No no.

$saveMethod = function($post, $db) { ... };
$event->append('globalsettings', new ExtendFormCheckbox('input_id', $saveMethod));
etc
ollehar

ollehar

2022-06-21 14:52

administrator   ~70431

We already have 2 form constructor : one for Survey and one for QuestionAttribute.

Let me read those again, then. But I doubt they are really flexible, nor object oriented...

DenisChenu

DenisChenu

2022-06-21 14:54

developer   ~70432

Let me read those again, then. But I doubt they are really flexible, nor object oriented...

Not really flexible … right.

ollehar

ollehar

2022-06-21 15:07

administrator   ~70433

OK, so how would you add a new select2 or datepicker as a survey setting...?

ollehar

ollehar

2022-06-21 15:10

administrator   ~70434

Ah, it's using the SettingsWidget. Also used by plugin settings, right? I thought about that one...

DenisChenu

DenisChenu

2022-06-21 15:12

developer   ~70435

Like always … «je me débrouille comme je peux»

example : https://gitlab.com/SondagesPro/OrcidAuthenticate/-/blob/master/views/admin/IntroductionSetting.php

ollehar

ollehar

2022-06-21 15:12

administrator   ~70436

Last edited: 2022-06-21 15:13

So you'd prefer $event->append('globalsettings.tab', ...settings widget data)?

DenisChenu

DenisChenu

2022-06-21 15:15

developer   ~70437

I prefer something easy and stable ;)

I think i already create a mantis issue about moving QuestoionAttributes + CoreForms + PluginSettings to same extension .

Else : i thionk have a definition array without need to create new object each time still instresting

ollehar

ollehar

2022-06-21 15:18

administrator   ~70438

Arrays require more writing than objects, tho. And they have no validation, or defaults. But a middle-ground is to have objects with $input->toSettingsWidget() function that converts them. Idk.

DenisChenu

DenisChenu

2022-06-21 15:24

developer   ~70439

Arrays require more writing than objects, tho.

?
You mean by core team ?

And they have no validation, or defaults.

core can offer some … PluginSettings have htmlOptions and current

$saveMethod = function($post, $db) { ... };
$event->append('globalsettings', new ExtendFormCheckbox('input_id', $saveMethod));

default saveMethod by core can be great
(for example : i think i creat an issue about save Plugin settings password encrypted by default …)

ollehar

ollehar

2022-06-21 15:25

administrator   ~70440

Idk, the settings widget is doing a lot of shit... Starting form tags, registering css and js files, ... It should have been an object hierarchy rather, SettingsWidgetButton, SettingsWidgetBoolean, etc, instead of a function for every setting type. Then it could have been reused in different contexts.

DenisChenu

DenisChenu

2022-06-21 15:28

developer   ~70441

Yes …
but : if you create another way, do you deprecated and removed old ways ?
And then : we have to redo whole plugins in 7 or 8 ?

ollehar

ollehar

2022-06-21 15:30

administrator   ~70442

default saveMethod by core can be great

Ya, but not sure how... xD Needs info about database table and column and validation. Basically model data.

$saveMethod = new DefaultSaveMethod('table', 'column', $validationRules);

??

ollehar

ollehar

2022-06-21 15:32

administrator   ~70443

but : if you create another way, do you deprecated and removed old ways ?
And then : we have to redo whole plugins in 7 or 8 ?

Urgh. No.

DenisChenu

DenisChenu

2022-06-21 15:34

developer   ~70444

Why not use PluginSettings table by default ?

When i mean default : a default table + way to save.
Plugin dev can replace by it's own function.

I already use PluginSettings table to save User related data.

DenisChenu

DenisChenu

2022-06-21 15:34

developer   ~70445

Urgh. No.

Then seem:s best to move (after) PluginSettings to the new ExtendForm system, no ?

ollehar

ollehar

2022-06-21 15:35

administrator   ~70446

We also have AdvancedSettingWidget and GeneralOptionWidget for question editor.

Already based on DTOs.

https://github.com/LimeSurvey/LimeSurvey/tree/master/application/extensions/GeneralOptionWidget/settings

DenisChenu

DenisChenu

2022-06-21 15:37

developer   ~70447

Yes,
And we have 2 separate system with a lot of same code …

PS : AdvancedSettingWidget are for QuestionAttribute

ollehar

ollehar

2022-06-21 15:37

administrator   ~70448

Why not use PluginSettings table by default ?

Hmmm, yes, this works, true.

DenisChenu

DenisChenu

2022-06-21 15:38

developer   ~70450

We also have AdvancedSettingWidget and GeneralOptionWidget for question editor.

Lack of optionnal htmlOptions (html5) and way to extend

ollehar

ollehar

2022-06-21 15:41

administrator   ~70451

What's HTML5 html options?

Extend how? Something else than new attributes?

DenisChenu

DenisChenu

2022-06-21 15:49

developer   ~70452

Oups …
I mean any attributes : min/max for number, pattern, disabled, placeholder etc … :)

ollehar

ollehar

2022-06-22 10:17

administrator   ~70477

Last edited: 2022-06-22 10:25

Actually, does this even need to be an event? We can have a service provider or module instead, where you can add input elements during system init. So.

// Plugin init
public function init()
{
  App()->extendedForm->append('globalsettings', new Input());
}

And then application code just fetch inputs from that service locator when needed.

DenisChenu

DenisChenu

2022-06-22 10:35

developer   ~70478

Need to be in API then , not in App only.

https://github.com/LimeSurvey/LimeSurvey/blob/master/application/libraries/PluginManager/LimesurveyApi.php

Then it's clearly set it can be used without issue since API version are not updated.

ollehar

ollehar

2022-06-22 10:37

administrator   ~70479

Hm, yes, correct.

Issue History

Date Modified Username Field Change
2022-06-21 13:10 ollehar New Issue
2022-06-21 13:10 ollehar Status new => assigned
2022-06-21 13:10 ollehar Assigned To => ollehar
2022-06-21 13:11 ollehar Note Added: 70423
2022-06-21 13:11 ollehar Bug heat 0 => 2
2022-06-21 13:12 ollehar Note Edited: 70423
2022-06-21 14:20 DenisChenu Note Added: 70424
2022-06-21 14:20 DenisChenu Bug heat 2 => 4
2022-06-21 14:30 ollehar Note Added: 70425
2022-06-21 14:36 DenisChenu Note Added: 70426
2022-06-21 14:37 ollehar Note Added: 70427
2022-06-21 14:39 ollehar Note Added: 70428
2022-06-21 14:39 ollehar Note Edited: 70428
2022-06-21 14:39 ollehar Note Edited: 70428
2022-06-21 14:44 DenisChenu Note Added: 70429
2022-06-21 14:52 ollehar Note Added: 70430
2022-06-21 14:52 ollehar Note Added: 70431
2022-06-21 14:54 DenisChenu Note Added: 70432
2022-06-21 15:07 ollehar Note Added: 70433
2022-06-21 15:10 ollehar Note Added: 70434
2022-06-21 15:12 DenisChenu Note Added: 70435
2022-06-21 15:12 ollehar Note Added: 70436
2022-06-21 15:12 ollehar Note Edited: 70436
2022-06-21 15:13 ollehar Note Edited: 70436
2022-06-21 15:15 DenisChenu Note Added: 70437
2022-06-21 15:18 ollehar Note Added: 70438
2022-06-21 15:24 DenisChenu Note Added: 70439
2022-06-21 15:25 ollehar Note Added: 70440
2022-06-21 15:28 DenisChenu Note Added: 70441
2022-06-21 15:30 ollehar Note Added: 70442
2022-06-21 15:32 ollehar Note Added: 70443
2022-06-21 15:34 DenisChenu Note Added: 70444
2022-06-21 15:34 DenisChenu Note Added: 70445
2022-06-21 15:35 ollehar Note Added: 70446
2022-06-21 15:37 DenisChenu Note Added: 70447
2022-06-21 15:37 ollehar Note Added: 70448
2022-06-21 15:38 DenisChenu Note Added: 70450
2022-06-21 15:41 ollehar Note Added: 70451
2022-06-21 15:49 DenisChenu Note Added: 70452
2022-06-22 10:17 ollehar Note Added: 70477
2022-06-22 10:25 ollehar Note Edited: 70477
2022-06-22 10:25 ollehar Note Edited: 70477
2022-06-22 10:35 DenisChenu Note Added: 70478
2022-06-22 10:37 ollehar Note Added: 70479