Пример #1
0
 /**
  * Method to validate the form data.
  *
  * @param   FOFForm  $form   The form to validate against.
  * @param   array    $data   The data to validate.
  * @param   string   $group  The name of the field group to validate.
  *
  * @return  mixed   Array of filtered data if valid, false otherwise.
  *
  * @see     JFormRule
  * @see     JFilterInput
  * @since   2.0
  */
 public function validateForm($form, $data, $group = null)
 {
     $params = JComponentHelper::getParams('com_babioonevent');
     $validateIsfreeofcharge = $params->get('showcharge', 2);
     if ($validateIsfreeofcharge == 2) {
         // Set charge to required to true when isfreeofcharge == 0
         $isfreeofcharge = is_object($data) ? $data->isfreeofcharge : $data['isfreeofcharge'];
         if ($isfreeofcharge == 0) {
             $form->setFieldAttribute('charge', 'required', 'true');
         }
     }
     $result = parent::validateForm($form, $data, $group);
     if ($validateIsfreeofcharge == 2) {
         if ($isfreeofcharge == 0) {
             $form->setFieldAttribute('charge', 'required', 'false');
         }
     }
     return $result;
 }