Hi Fumito! Thanks for this feature, it is indeed a usefull one.
By Victor ALBERT , 6 January 2015 ·

We would be glad to accept your PR, however we wonder if the JS part could not be done in a cleaner way.

Instead of doing a "sprintf", could you consider writing a JS file? There could be a function taking at least two arguments : a type, and an array ($json).

This could be done like this :

  1. A JS file provides a function init_form_condition which will test a type and does some stuff according to that type (it is basically what you do in yout config file)
  2. add the function with \Nos\Nos::main_controller()->addJavascript('path/to/js/file')
  3. call the JS function by using
    \Nos\Nos::main_controller()->addJavascriptInline('init_form_condition('. $type . ', '. $json.');')

Don't hesitate to tell us if something bother you :)

Can't wait to read from you (or see your PR!).

Hello, Victor,

Thank you for your suggestion.

The reason I use "sprintf" using PHP is,
"Support for two (or more) Radio buttons."

The function name is check_option_%1$s, which differs for each field.


This allows to create a form like this;
Q1 (radio): A, B, or Other
Q2 (text): shown if Q1=Other
Q3 (radio): C, D, or Other
Q4 (text): shown if Q3=Other

I'm OK to do this logic in a JS file. I think it's a better way, but I failed to create a JS which allow this.
By Fumito MIZUNO , 7 January 2015 ·

As you use the field name (which is unique in your current form) to attach your handler and to test your values, I'm not sure that I see why you need to create a specific handler for each field.

Could you take a look at the attached file and tell me if this could suit you?

Please forgive me if I misunderstood your problem!

I look forward to reading you :)
By Victor ALBERT , 7 January 2015 ·

Thank you for creating condition.js

The problem is,

$('input[name="'+json.inputname+'"]').change(function() {
check_option(type, json);

need to be repeatable, like this;

$('input[name="'+json1.inputname+'"]').change(function() {
check_option(type, json);
$('input[name="'+json2.inputname+'"]').change(function() {
check_option(type, json);

I failed to handle this problem. (I know PHP well, but not JS.)
By Fumito MIZUNO , 7 January 2015 ·
Probably, this code will work.

$('input').change(function() {
check_option(type, json);
$('select'').change(function() {
check_option(type, json);

This code will run each field is changed, it maybe a loss.
By Fumito MIZUNO , 7 January 2015 ·
The loop in front controller will get through every field, so that "json" var will change at every step.
By Victor ALBERT , 7 January 2015 ·

Then, by calling the "addJavascriptInline" in it, you will attach a handler on every concerned field.
This would make it "repeatable".

And you're perfectly right about dealing with "select" differently, but instead of attaching it on every field, you can write something like this :

$('[name="'+json.inputname+'"]').change(function() {
check_option(type, json);

This will attach the handler on a markup with this very specific name attribute, regardless of its nature (input or select).

I think we're coming to a solution, aren't we? :)

Let me know if this works fine!

Hello, Victor,

Thank you.

I finally succeed in creating JS codes.

My previous replies comes from my miss understanding. I'm sorry.
By Fumito MIZUNO , 8 January 2015 ·
Hi Fumito,

Glad I could discover your PR today :)

The rest of our team will now take a closer a look, but I don't see any reason why we would not accept it.

Thanks for this usefull feature!
By Victor ALBERT , 8 January 2015 ·
    ou Annuler
noviusos_form: When I select "Other", another textarea is shown to fill in the details
By Fumito MIZUNO , 5 January 2015


I modified noviusos_form. I added a condition field-group for each text/radio/checkbox etc.


Some forms are shown when the condition is met.

Example Usage: When I select "Other", another textarea is shown to fill in the details.


In the picture shown below,

Form name to Check: => radio_1
Show when the value is: => Other

The field is shown when the value of radio_1 field is Other.

Form name to Check is a virtual name, in the Technical options field-group.
So it assumes "expert view." 

Do you like the idea? If yes, I will make a pull request.

1 user voted for this idea.