Skip to content

Commit

Permalink
Dev: added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jan 20, 2017
1 parent 0c64e38 commit 7ee3b0b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions templates/default/views/subviews/start_form.twig
@@ -1,11 +1,25 @@
{#
This file generate the opening form tag and the CRSF token
LimeSurvey
Copyright (C) 2007-2017 The LimeSurvey Project Team / Louis Gac
All rights reserved.
License: GNU/GPL License v2 or later, see LICENSE.php
LimeSurvey is free software. This version may have been modified pursuant
to the GNU General Public License, and as distributed it includes or
is derivative of works licensed under the GNU General Public License or
other free or open source software licenses.
See COPYRIGHT.php for copyright notices and details.
(¯`·._.·(¯`·._.· Start Form ·._.·´¯)·._.·´¯)
This file generate the opening form tag and the CRSF token for the main survey Form.
eg:
<form enctype="multipart/form-data" id="limesurvey" name="limesurvey" autocomplete="off" class="survey-form-container" action="index.php/289445" method="post">
<input type="hidden" value="393e1f3e91d6fb062b8c67d39771bb674de337ca" name="YII_CSRF_TOKEN">
It use the Yii fuction CHtml::form
It uses the Yii fuction CHtml::form
@see: http://www.yiiframework.com/doc/api/1.1/CHtml#form-detail
The hidden submit button is used for any submittion (triggered via JS event)
#}

{#
Expand Down Expand Up @@ -38,5 +52,8 @@
)
}}

<!-- Field Names -->
<input type='hidden' name='fieldnames' value='{{ aSurveyInfo.hiddenfieldnames }}' id='fieldnames' />

<!-- Submit button -->
<button type="submit" id="defaultbtn" value="default" name="move" class="submit hidden" style="display:none">{{'default'|t}}</button>

8 comments on commit 7ee3b0b

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? This 2 hidden input must not be included by PHP core code directly ? Like the YII_CRSF_TOKEN in fact ?

@LouisGac
Copy link
Contributor

@LouisGac LouisGac commented on 7ee3b0b Jan 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the HTML is rendered at once from the the twig layout, and then the inclusions. We can't keep any rendering process by echoing strings from SurveyRuntime helper (that was the main goal of all that process).

Maybe we could still force it to be "core" by changing the inclusion path of that file, and putting it outside of template. But what would be the benefit?

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Less easy for a template dev to break form function (YII_CRSF_TOKEN)
  2. More easy for us to add/remove some needed/uneeded input.
  3. Better separation between : it's a PHP issue VS it's a template issue => clearly input name are/form type/hidden input are not template issues.

Maybe : C.Html.form to C.Html.lsform ?

I don't like too to have enctype in form ... :\

@LouisGac
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but what if a survey creator want to add new attributes to the main form?

https://github.com/LimeSurvey/LimeSurvey/blob/twig-layout/templates/default/views/subviews/start_form.twig#L27

Or if they want to completely remove the form logic, for example to do some 100% ajax stuff putting all the questions outside the form itself ? Or if they want to completely change the logic of the hidden submit button?

Here, survey creators are free to do what ever they want, and maybe they will use those new possibilities to do things we just can't imagine right now.

On our side, if we change the hidden filed name logic, or the form logic, it will completely break all the custom JS, workarounds, etc. forcing us to publish a new major version... So, making that part a core feature will not make it easier to update those logic.

@Shnoulle
Copy link
Collaborator

@Shnoulle Shnoulle commented on 7ee3b0b Jan 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Survey VS template VS extension/plugin

On our side, if we change the hidden filed name logic, or the form logic,

But here : you put the breaking things, no ?

@LouisGac
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, anything in rendering is now a template feature.

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then no extension can render something ?

@LouisGac
Copy link
Contributor

@LouisGac LouisGac commented on 7ee3b0b Jan 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In joomla, you have three layers:

Templates, Modules, plugins.

We're getting much closer to that logic. But maybe it will be better that we discuss about that on the IRC.

Please sign in to comment.