AnsweredAssumed Answered

Make Field required by term of other field

Question asked by Asaf Army on Jan 22, 2017
Latest reply on Jan 22, 2017 by Asaf Army

Hello Programmers,

 

i implemented a code that when choosing a value in one dropdown, the other dropdown turns to Required.

i added a call to OnChange() in the first dropdown, in the editviewdefs.php and quickcreatedefs.php files:

 

'displayParams' =>
array (
'field' =>
array (
'onChange' => 'updatedocTypeDropDown(this.value);',
),
),

 

and in a javascript file i made the other dropdown, as required, using addToValidate():

 

if ( dropdownSelectionValue == 'cancel')
{

   if ( document.getElementById('charge_type_c') != null)
   {
      addToValidate('EditView','charge_type_c','varchar',true,'');
      $('#charge_type_c_label').html('Hello: <font color="red">*</font>'); // with red * sign next to label
   }

}

 

it works great.

when changing the value in the first dropdown, the other dropdown turns to required and the system cancels the save when the user push "save" button, as long as no value was chosen in the second dropdown.

 

The problem is that it works perfectly only in the Editview but not in the QuickCreate!

In the quickcreate the code activates and the red dot near the second dropdown shows, but the system does not block the save eventhough no value chosen in the second dropdown.

 

really need your help, because it means there is not way to turn fields into required in quickcreate at all.

why is that and how can i fix it?

Outcomes