Here are the instructions, but they probably require that you adjust the code to make it suite your installation.
My code works if you create from scratch the following two fields from Admin->Studio>Invoices:
(follow the screenshots exactly):
Create Dropdown field:
then:
Now create Text field:
then:
Once done proceed to modify the layout of the Edit View:
Now you are ready to add some php code:
Look for a file called: custom/modules/AOS_Invoices/views/view.edit.php
if it doesn’t already exist then create it and paste the following code inside it:
class AOS_InvoicesViewEdit extends ViewEdit
{
public function display(){
parent::display();
$javascript = <<<'EOT'
<script type="text/javascript">
window.onload=function(){
function toggle_extra_field() {
if(xx_extra_field.value == 0) {
document.querySelector('div[data-label="LBL_DFLH_EXTRA_FIELD"]').style.display='none';
document.querySelector('div[field="dflh_extra_field_c"]').style.display='none';
}
if(xx_extra_field.value == 1) {
document.querySelector('div[data-label="LBL_DFLH_EXTRA_FIELD"]').style.display='';
document.querySelector('div[field="dflh_extra_field_c"]').style.display='';
var xx_extra_field_sub = document.getElementById('dflh_extra_field_c');
xx_extra_field_sub.value = '';
}
}
var xx_extra_field = document.getElementById('dflh_bool_show_extra_field_c');
toggle_extra_field();
xx_extra_field.addEventListener('change', toggle_extra_field, false);
}
</script>
EOT;
echo $javascript;
exit;
}
}
if it already exist you should open it and look for a line with:
public function display(){
or
public function display()
{
or
function display(){
or
function display()
{
if you can’t find it then, after the lines
class AOS_InvoicesViewEdit extends ViewEdit
{
paste the following code:
public function display(){
parent::display();
$javascript = <<<'EOT'
<script type="text/javascript">
window.onload=function(){
function toggle_extra_field() {
if(xx_extra_field.value == 0) {
document.querySelector('div[data-label="LBL_DFLH_EXTRA_FIELD"]').style.display='none';
document.querySelector('div[field="dflh_extra_field_c"]').style.display='none';
}
if(xx_extra_field.value == 1) {
document.querySelector('div[data-label="LBL_DFLH_EXTRA_FIELD"]').style.display='';
document.querySelector('div[field="dflh_extra_field_c"]').style.display='';
var xx_extra_field_sub = document.getElementById('dflh_extra_field_c');
xx_extra_field_sub.value = '';
}
}
var xx_extra_field = document.getElementById('dflh_bool_show_extra_field_c');
toggle_extra_field();
xx_extra_field.addEventListener('change', toggle_extra_field, false);
}
</script>
EOT;
echo $javascript;
exit;
}
If yo ahve already created the two fields yu have to adjust the code I provided with the names of the fields you have created. Please try exacty as I instruted you and post back any issues.