use variable to avoid multiple method calls

This commit is contained in:
Marc Michalsky 2023-08-17 10:08:51 +02:00
parent e442ca6249
commit 3241583542
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -191,22 +191,25 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
break; break;
} }
// Is this the default profile?
$is_default = $this->profile->is_default();
// Assign template variables. // Assign template variables.
$this->assign('op', $this->_op); $this->assign('op', $this->_op);
$this->assign('profile_name', $profile_name); $this->assign('profile_name', $profile_name);
$this->assign('is_default', $this->profile->is_default()); $this->assign('is_default', $is_default);
// Add form elements. // Add form elements.
$this->add( $this->add(
'text', // field type 'text', // field type
'name', // field name 'name', // field name
E::ts('Profile name'), E::ts('Profile name'),
['class' => 'huge'] + ($this->profile->is_default() && $this->_op == 'edit' ? ['readonly'] : []), ['class' => 'huge'] + ($is_default && $this->_op == 'edit' ? ['readonly'] : []),
!$this->profile->is_default() !$is_default
); );
// Do only display selector if this is not the default profile // Do only display selector if this is not the default profile
if (!$this->profile->is_default()) { if (!$is_default) {
$this->add( $this->add(
'text', // field type 'text', // field type
'selector', // field name 'selector', // field name