Forums

hide from field i

chuanse 26 Jul, 2015
I am aware I can hide/show a form field with JS if for example a radiobutton is selected or not-selected.

But how can I show or hide a required field (text area) if $form->data['somevalue'] = 0 or 1

Goal: on second page of multipage form:

a user with value $form->data['exception'] = 0 should not see the textarea

a user with value $form->data['exception'] = 1 should see the textarea
GreyHead 27 Jul, 2015
HI chaunse,

The simplest way to do this is probably to use CSS
<?php
$display = 'none';
if ( $form->data['exception'] == 1 ) {
  $display = 'block';
}
$jdoc = \JFactory::getDocument();
$style = "
#id_of_parent {
  display: ($display};
}
";
$jdoc->addStyleDeclaration();
?>

Bob
This topic is locked and no more replies can be posted.