Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-2696

Edit Custom Fields : Erroneous form validation error occurs when saving an existing custom field - "Option Type is a required field"

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      This problem occurs when there are not option groups linked to custom fields (yet). So to recreate - start with a DB that does NOT have sample data loaded. Then create a custom field type = Yes / No. Save the field, then go to edit it and try to save it again. You'll get the form validation error on the option_type field.

      NOTE: if you create a select, radio or checkbox field first - you won't see this bug.

      The cause of this is that the code goes to this condtion (Custom/Field.php):

      if ( empty( $optionGroups ) ) {
      $optionTypes = array( '1' => ts( 'Create a new set of options' ) );
      $extra = array( 'onclick' => "showOptionSelect();");
      $element =& $this->addRadio( 'option_type',
      ts('Option Type'),
      $optionTypes,
      $extra,
      '<br/>', true
      );
      $element->freeze( );

      ... and if you do a view source - the option_type field actually doesn't exist in the source (it would be hidden and frozen in any case) .

      I'm not sure what the right fix is? Maybe we need to make the presence of that "required" field conditional when in UPDATE mode - not add it to the form object when the HTML type is not checkbox, radio or mult-select.

        Attachments

          Activity

            People

            • Assignee:
              kiran.jagtap Kiran Jagtap
              Reporter:
              dgg David Greenberg
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: