I have a field which is conditionally hidden depending on the value of another field. It is also defined as a mandatory field via PHP getForm Method:
if(JFactory::getApplication()->isSite() && $form->getValue('type') == "printer") {
$form->setFieldAttribute('status_printer', 'required', 'true');
}
The field also has no default value.
In the scenario when the field is hidden, a value 1 should be written in this field when saving.
I use PHP (save method - after data modeling) for this:
$data['status_printer'] = 1;
This method writes the value 1 when saving, but only if the field is not defined as required.
I don't want to define a default value in this field because if it is not hidden the user should enter his own value.
My general question: is it even possible that the value 1 is written in a hidden mandatory field when saving?
Thanks in advance