Dynamic Text Field

I’m looking for some specific direction on creating a dynamic text area. This would ideally work in conjunction with a dependent dynamic drop down. Here is my scenario…

I currently have a working parent dropdown that dynamically changes the options of the connected child dropdown list. I would like to take this one step further and have a text area populate a description of the selected item from the child dropdown list.

For Example:

Parent: Drop Down = categories
child dropdown = items
Text area = prepopulated description of the selected item.

let me know if I need to clarify what I’m asking for. The reason for this scenario is that I have a custom built class module and the current parent drop down equals my course categories and when a category is selected in my course classes drop down it only shows me my classes for the selected course category like it should. I have text area for the course description, but I have to copy and paste that in every time. I then create certificate from the module for the attendees of the class. I know that I could make several templates with the description included but this would leave me with hundreds of templates to sort through which leaves room to select the wrong template.

I could probably have a workflow set up for every item as well and when it is selected it would populate the field upon saving it but then I believe I would have many quires running all the time.(not sure how this would impact server performance if any)

the only other solution I can think of is to create a dynamic text area based off the child dropdown list?

Any suggestions or opinions would be welcome.

My suggestion to achieve this would be to add custom JavaScript (Jquery) to the edit view which takes the value of the connected child dropdown and passes it via an ajax call to a custom controller action in your module. The controller action will return the correct description text based on the value you passed to it. The Javascript then updates the text area with the returned text. Simples :wink:

Hi

You can modify your custom editviewdefs.php to put onchange on the drop-down and then call JavaScript to hide/show the fields.

In custom/modules// metadata/editviewdefs.php

1 => array (
‘name’ => ‘yourfield’,
‘label’ => 'LBL_YOURFIELD,
‘displayParams’ =>
array (
‘field’ =>
array (
‘onChange’ => ‘hideFields()’,
),
),
‘tabindex’ => ‘12’,
),
),

to include a JavaScript file in editviewdefs

1 => array (
‘label’ => ‘10’,
‘field’ => ‘30’,
),
),
‘includes’ =>
array (
0 =>
array (
‘file’ => ‘custom/include/showhide.js’,
),

		),
  'useTabs' => false,
),

Then you can put the JS function to call in your javascript file as following.

Let say the Drop-down is x_dd and the field y_fld.

If you need to hide a field form layout when specific option selected from dropdown, you have to hide the field as well as hide its label. So we need to hide the parent

of the field as well as of label of field.

Now, if you check html source that field the ID for the Label TD will be like “y_field_label” and ID for the filed will be the name of the field.

Let say the function on dropdown on change is “hidefield”.

function hidefield(){
if ($("#x_dd").val() = “some-value”) {
$("#y_field_label").hide();
$("#y_field").closest(“td”).hide();
}else{
$("#y_field_label").show();
$("#y_field").closest(“td”).show();
}
}

Try thi…

Hi, sorry to open an old post, but it semms to be exactly what I need.

But I don’t understand how to modify editviewdefs.php

here my modification if someone can help me I think I don’t write correctly this part :

Syntaxe error I think
(here all the editviewdefs.php if someone can help he’s welcome :wink: )

“surface_habitation_c” is the field I have to hide

With this file the edit views stay blank … hum

<?php
$module_name = 'AOS_Contracts';
$viewdefs [$module_name] = 
array (
  'EditView' => 
  array (
    'templateMeta' => 
    array (
      'maxColumns' => '2',
      'widths' => 
      array (
        0 => 
        array (
          'label' => '10',
          'field' => '30',
        ),
        1 => 
        array (
          'label' => '10',
          'field' => '30',
        ),
      ),
      'useTabs' => false,
      'syncDetailEditViews' => true,
      'tabDefs' => 
      array (
        'DEFAULT' => 
        array (
          'newTab' => false,
          'panelDefault' => 'expanded',
        ),
        'LBL_LINE_ITEMS' => 
        array (
          'newTab' => false,
          'panelDefault' => 'expanded',
        ),
      ),
    ),
    'panels' => 
    array (
      'default' => 
      array (
        0 => 
        array (
          0 => 'name',
          1 => 
          array (
            'name' => 'status',
            'studio' => 'visible',
            'label' => 'LBL_STATUS',
          ),
        ),
        1 => 
        array (
          0 => 
          array (
            'name' => 'total_contract_value',
            'label' => 'LBL_TOTAL_CONTRACT_VALUE',
          ),
          1 => 
          array (
            'name' => 'assigned_user_name',
            'label' => 'LBL_ASSIGNED_TO_NAME',
          ),
        ),
        2 => 
        array (
          0 => 
          array (
            'name' => 'start_date',
            'label' => 'LBL_START_DATE',
          ),
          1 => 
          array (
            'name' => 'contract_account',
            'label' => 'LBL_CONTRACT_ACCOUNT',
          ),
        ),
        3 => 
        array (
          0 => 
          array (
            'name' => 'end_date',
            'label' => 'LBL_END_DATE',
          ),
          1 => 
          array (
            'name' => 'contact',
            'studio' => 'visible',
            'label' => 'LBL_CONTACT',
          ),
        ),
        4 => 
        array (
          0 => 
          array (
            'name' => 'renewal_reminder_date',
            'label' => 'LBL_RENEWAL_REMINDER_DATE',
            'type' => 'datetimecombo',
          ),
          1 => 
          array (
            'name' => 'opportunity',
            'label' => 'LBL_OPPORTUNITY',
          ),
        ),
        5 => 
        array (
          0 => 
          array (
            'name' => 'type_de_contrat_c',
            'studio' => 'visible',
            'label' => 'LBL_TYPE_DE_CONTRAT',
          ),
          1 => 
          array (
            'name' => 'sous_type_contrats_c',
            'studio' => 'visible',
            'label' => 'LBL_SOUS_TYPE_CONTRATS',
          ),
        ),
        6 => 
        array (
          0 => 
          array (
            'name' => 'surface_habitation_c',
            'label' => 'LBL_SURFACE_HABITATION',
	'displayParams' =>
	array (
	'field' =>
	array (
	'onChange' => 'hideFields()',
	),
	),
	'tabindex' => '12',
          ),
        ),
	'label' => '10',
	'field' => '30',
	),
	),
	'includes' =>
	array (
	0 =>
	array (
	'file' => 'custom/include/showhide.js',
	),
	),
	'useTabs' => false,
	),
        7 => 
        array (
          0 => 
          array (
            'name' => 'created_by_name',
            'label' => 'LBL_CREATED',
          ),
          1 => 
          array (
            'name' => 'cheminee_c',
            'label' => 'LBL_CHEMINEE',
          ),
        ),
        8 => 
        array (
          0 => 
          array (
            'name' => 'nombre_de_pieces_c',
            'label' => 'LBL_NOMBRE_DE_PIECES',
          ),
          1 => 
          array (
            'name' => 'immatriculation_vehicule_c',
            'label' => 'LBL_IMMATRICULATION_VEHICULE',
          ),
        ),
        9 => 
        array (
          0 => 
          array (
            'name' => 'reference_code',
            'label' => 'LBL_REFERENCE_CODE ',
          ),
          1 => 
          array (
            'name' => 'pieces_manquantes_c',
            'studio' => 'visible',
            'label' => 'LBL_PIECES_MANQUANTES',
          ),
        ),
        10 => 
        array (
          0 => 
          array (
            'name' => 'customer_signed_date',
            'label' => 'LBL_CUSTOMER_SIGNED_DATE',
          ),
        ),
        11 => 
        array (
          0 => 
          array (
            'name' => 'company_signed_date',
            'label' => 'LBL_COMPANY_SIGNED_DATE',
          ),
        ),
        12 => 
        array (
          0 => 'description',
        ),
      ),
      'lbl_line_items' => 
      array (
        0 => 
        array (
          0 => 
          array (
            'name' => 'currency_id',
            'studio' => 'visible',
            'label' => 'LBL_CURRENCY',
          ),
        ),
        1 => 
        array (
          0 => 
          array (
            'name' => 'line_items',
            'label' => 'LBL_LINE_ITEMS',
          ),
        ),
        2 => 
        array (
          0 => 
          array (
            'name' => 'total_amt',
            'label' => 'LBL_TOTAL_AMT',
          ),
        ),
        3 => 
        array (
          0 => 
          array (
            'name' => 'discount_amount',
            'label' => 'LBL_DISCOUNT_AMOUNT',
          ),
        ),
        4 => 
        array (
          0 => 
          array (
            'name' => 'subtotal_amount',
            'label' => 'LBL_SUBTOTAL_AMOUNT',
          ),
        ),
        5 => 
        array (
          0 => 
          array (
            'name' => 'shipping_amount',
            'label' => 'LBL_SHIPPING_AMOUNT',
            'displayParams' => 
            array (
              'field' => 
              array (
                'onblur' => 'calculateTotal(\'lineItems\');',
              ),
            ),
          ),
        ),
        6 => 
        array (
          0 => 
          array (
            'name' => 'shipping_tax_amt',
            'label' => 'LBL_SHIPPING_TAX_AMT',
          ),
        ),
        7 => 
        array (
          0 => 
          array (
            'name' => 'tax_amount',
            'label' => 'LBL_TAX_AMOUNT',
          ),
        ),
        8 => 
        array (
          0 => 
          array (
            'name' => 'total_amount',
            'label' => 'LBL_GRAND_TOTAL',
          ),
        ),

	      ),
    ),
  ),
);
?>

sorry for my english, and noob question…

Hi Andrew,

Please tell me what is javascript function to get dropdown value of related record?

Thanks