Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule for separation #11916

Closed
wants to merge 1 commit into from
Closed

Add rule for separation #11916

wants to merge 1 commit into from

Conversation

elgui02
Copy link

@elgui02 elgui02 commented Apr 1, 2018

Issue CRM-21859
Form for adding activities doesn't validate field Activity Separation when is called from list of contacts

Overview

Resolve issue when create an activity from contact search and can make a separation this separation isn't required

Before

Open page "Find Contacts" and click "Search"
Select first 50 records
Click on "Actions" field and choose "Add activity" (Selected contacts are in With contacts field)
Choose Meeting, clear Date and Time fields
Click Save button
Effect: The form doesn't validate the field "Activity Separation" and activity is created. There should be a warning "Activity Separation is a required field"

After

Open page "Find Contacts" and click "Search"
Select first 50 rekords
Click on "Actions" field and choose "Add activity" (Selected contacts are in With contacts field)
Choose Meeting, clear Date and Time fields
Click Save button
Effect: The form validate the field "Activity Separation" and activity is created and show a warning "Activity Separation is a required field"

Technical Details

Just add a rule for make required a separation when this is created


Issue CRM-21859
Form for adding activities doesn't validate field Activity Separation when is called from list of contacts
@civicrm-builder
Copy link

Can one of the admins verify this patch?

@seamuslee001
Copy link
Contributor

Jenkins ok to test

@eileenmcnaughton
Copy link
Contributor

I just spotted a risk here - the separation field is not always added to the form - so making it always required would potentially make a non-existent field required.

    $separationIsPossible = $this->supportsActivitySeparation;
    if ($actionIsAdd && $separationIsPossible) {
      $this->addRadio(
        'separation',
        ts('Activity Separation'),
        array(
          'separate' => ts('Create separate activities for each contact'),
          'combined' => ts('Create one activity with all contacts together'),
        )
      );
    }

Suggestion
the addRadio function takes 'required' as a parameter so add there

@elgui02
Copy link
Author

elgui02 commented Apr 2, 2018

If you view all if there is where rule is created

// Add the "Activity Separation" field
$actionIsAdd = $this->_action != CRM_Core_Action::UPDATE;
$separationIsPossible = $this->supportsActivitySeparation;
if ($actionIsAdd && $separationIsPossible) {
$this->addRadio(
'separation',
ts('Activity Separation'),
array(
'separate' => ts('Create separate activities for each contact'),
'combined' => ts('Create one activity with all contacts together'),
)
);
$this->addRule('separation', ts('Activity separation is a required field'), 'required');
}

@eileenmcnaughton
Copy link
Contributor

AH ok - what does adding a required rule add compared to passing the param required? (I think the latter is more common)

@eileenmcnaughton
Copy link
Contributor

@yashodha this seems to tie in with a ticket you logged so perhaps you could review it?

@eileenmcnaughton
Copy link
Contributor

Cross referencing with #12223

@eileenmcnaughton
Copy link
Contributor

eileenmcnaughton commented Jul 24, 2018

I still think this should be passin $isRequired not addin a rule

$this->addRadio(
'separation',
ts('Activity Separation'),
array(
'separate' => ts('Create separate activities for each contact'),
'combined' => ts('Create one activity with all contacts together'),
),
NULL,
TRUE
);

calling

  public function &addRadio($name, $title, $values, $attributes = array(), $separator = NULL, $required = FALSE) {

@eileenmcnaughton
Copy link
Contributor

I'm gonna close for now & you can re-open if you address - I think maybe you've moved on as no reply to comment in April

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants